Documentation tools for AI agents — fetch library docs, search semantically, scrape websites cleanly.
- 📚 Library Docs - Instant access to 1000+ libraries via Context7 API
- 🔍 Semantic Search - Natural language Q&A over documentation targets
- 🌐 Web Scraping - Clean markdown extraction from any website
- 💾 Smart Caching - Automatic deduplication and content organization
- ⚡ Token Efficient - Optimized responses to avoid context bloat
- 🎯 Resource Discovery - MCP resources expose available targets for agents
npx -y github:ain3sh/context-mcpNo installation required. Always uses the latest version.
git clone https://github.com/ain3sh/context-mcp.git
cd context-mcp
npm install
npm run build
npm startAdd to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"context-mcp": {
"command": "npx",
"args": ["-y", "github:ain3sh/context-mcp"],
"env": {
"GEMINI_API_KEY": "your_api_key_here"
}
}
}
}Create .mcp.json in your project root:
{
"mcpServers": {
"context-mcp": {
"type": "stdio",
"command": "npx",
"args": ["-y", "github:ain3sh/context-mcp"],
"env": {
"GEMINI_API_KEY": "${GEMINI_API_KEY}"
}
}
}
}| Tool | Purpose | Token Usage |
|---|---|---|
fetch_docs |
Get library/framework documentation | ~5k-50k tokens |
fetch_site |
Scrape webpage → clean markdown | ~2k-20k tokens |
ask_docs_agent |
Semantic Q&A over documentation | ~500-3k tokens |
Fetch documentation for any library or framework from Context7's massive index.
// Simple library fetch
fetch_docs({
target: "react"
})
// Specific topic within a library
fetch_docs({
target: "pytorch",
tag: "autograd"
})
// Control documentation depth
fetch_docs({
target: "pandas",
depth: "high" // ~50k tokens for comprehensive docs
})
// Browse available versions
fetch_docs({
target: "tensorflow",
browse_index: true
})| Param | Type | Default | Description |
|---|---|---|---|
target |
string | required | Library name (fuzzy matching supported) |
tag |
string | - | Topic filter within library |
depth |
"low" | "medium" | "high" |
"medium" |
Documentation comprehensiveness (~5k/15k/50k tokens) |
version |
string | - | Specific version to fetch |
browse_index |
boolean | false |
List available libraries instead of fetching docs |
Query → Context7 API → Smart matching → Filtered docs → Markdown response
Context7 maintains pre-indexed documentation for 1000+ libraries. The tool uses fuzzy matching, so "tf" finds "tensorflow", "pd" finds "pandas", etc.
Extract clean, readable content from any website using Mozilla's Readability algorithm.
// Single page extraction
fetch_site({
url: "https://arxiv.org/abs/2301.00234"
})
// Include images
fetch_site({
url: "https://example.com/tutorial",
images: true
})
// Batch fetch multiple URLs
fetch_site({
url: [
"https://site.com/page1",
"https://site.com/page2",
"https://site.com/page3"
]
})
// Force refresh cached content
fetch_site({
url: "https://news.site/article",
refresh: true
})| Param | Type | Default | Description |
|---|---|---|---|
url |
string | string[] | required | URL(s) to fetch (max 10 for batch) |
images |
boolean | false |
Fetch and save images alongside content |
refresh |
boolean | false |
Bypass cache and re-fetch |
Content is saved to disk and returned:
./context/
└── understanding-react-hooks/ # Auto-named from page title
├── CONTENT.md # Markdown with YAML frontmatter
└── images/
└── diagram.jpg
URL → Fetch → JSDOM → Readability → Turndown → Clean Markdown
Uses the same extraction algorithm as Firefox Reader View to remove ads, navigation, and clutter.
AI-powered semantic search over documentation stores using Gemini File Search.
Requires: GEMINI_API_KEY environment variable (get one here)
// Simple question
ask_docs_agent({
target: "context",
query: "How does chunking work in File Search?"
})
// Include source chunks for verification
ask_docs_agent({
target: "my-docs",
query: "authentication setup",
include_chunks: true,
top_k: 5
})
// Get structured JSON response
ask_docs_agent({
target: "api-docs",
query: "rate limits",
format: "json"
})| Param | Type | Default | Description |
|---|---|---|---|
query |
string | required | Natural language question (5-500 chars) |
target |
string | required | Documentation store name |
top_k |
int | 3 |
Number of relevant chunks to retrieve (1-20) |
include_chunks |
boolean | false |
Include chunk previews in response |
format |
"markdown" | "json" |
"markdown" |
Response format |
metadata_filter |
string | - | Advanced: List Filter syntax for file filtering |
Query the docs://targets MCP resource to see what's available:
{
"targets": [
{ "target": "my-api-docs", "id": "...", "createTime": "...", "updateTime": "..." }
],
"total": 1
}Use docs://targets/{name} for details on a specific target.
Default (markdown, no chunks): ~500-1000 tokens
# Search Results: context
**Query**: How does chunking work?
**Response**:
Files are automatically chunked when imported into a file search store...
---
**Sources** (2 files):
- ai.google.dev_gemini-api_docs_file-search.md
- technical_spec.mdWith chunks: ~2000-3000 tokens
[... same as above, plus ...]
---
## Retrieved Context Chunks
### [1] ai.google.dev_gemini-api_docs_file-search.md
Files are automatically chunked when imported...
[truncated to 500 chars]Query → Gemini File Search API → Semantic retrieval → LLM synthesis → Cited response
Queries pre-indexed Gemini FileSearchStores in the cloud. The stores must be created separately (e.g., via GitHub Actions workflow).
| Variable | Required | Description |
|---|---|---|
GEMINI_API_KEY |
For ask_docs_agent |
Your Gemini API key for semantic search |
CONTEXT7_API_KEY |
No | Higher rate limits for fetch_docs (optional) |
FETCH_SITE_CONTENT_DIR |
No | Content storage directory (default: ./context) |
LOG_LEVEL |
No | debug, info, or error (default: info) |
This server is optimized to minimize context usage:
| Tool | Typical Usage | Maximum |
|---|---|---|
fetch_docs with depth="low" |
~5k tokens | 10k |
fetch_docs with depth="medium" |
~15k tokens | 30k |
fetch_docs with depth="high" |
~50k tokens | 100k |
fetch_site (single page) |
~2-5k tokens | 20k |
ask_docs_agent (default) |
~500-1k tokens | 2k |
ask_docs_agent with chunks |
~2-3k tokens | 5k |
- Try variations of the name (e.g., "tf" vs "tensorflow")
- Use
browse_index: trueto see available libraries - Check if you need a specific version
- Some sites block automated access
- Try
refresh: trueto bypass cache - Check if the site requires authentication
- Query
docs://targetsresource to see available targets - Verify the target name matches exactly
- Check that
GEMINI_API_KEYis set correctly
- Free tier: ~15 queries per minute
- Wait 60 seconds between bursts
- Consider upgrading Gemini API tier if needed
- Run
npm run buildto compile TypeScript - Check MCP config JSON is valid
- Review client logs (e.g.,
~/Library/Logs/Claude/mcp*.log) - Test manually:
GEMINI_API_KEY=key npx -y github:ain3sh/context-mcp
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run development mode (auto-reload)
npm run dev
# Test with environment
GEMINI_API_KEY=your_key npm startnpm run build
timeout 5s GEMINI_API_KEY=your_key npx .context-mcp/
├── src/
│ └── index.ts # MCP server implementation
├── dist/
│ └── index.js # Compiled output
├── context/ # Cached content (git-ignored)
├── package.json
└── tsconfig.json
MIT License – see LICENSE