
Code Reference Optimizer MCP Server
Extracts minimal, relevant code context from multiple programming languages while analyzing diffs and optimizing imports to reduce token usage for AI assistants. Supports TypeScript/JavaScript, Python, Go, and Rust with token-aware caching.
README
Code Reference Optimizer MCP Server
An MCP (Model Context Protocol) server that extracts minimal, relevant code context, analyzes diffs, and optimizes imports to reduce token usage for AI assistants.
- Multi-language parsing (TypeScript/JavaScript, Python, Go, Rust)
- Token-aware caching and minimal diffs
- Simple stdio server, easy to integrate with MCP clients
Quick Start
- One-off (recommended):
npx -y @fosterg4/mcpsaver
You should see: Code Reference Optimizer MCP server running on stdio
.
- Global (optional):
npm i -g @fosterg4/mcpsaver
mcpsaver
Use with an MCP client
Add to your MCP client config (example mcpServers.json
):
{
"mcpServers": {
"mcpsaver": {
"command": "npx",
"args": ["-y", "@fosterg4/mcpsaver"],
"env": {}
}
}
}
Available Tools (exact schemas)
These map 1:1 to the server in src/index.ts
.
-
extract_code_context
- Input:
Required:{ "filePath": "path/to/file.ts", "targetSymbols": ["myFunc", "MyClass"], "includeImports": true, "maxTokens": 1000 }
filePath
. Optional:targetSymbols
,includeImports
(default true),maxTokens
(default 1000).
- Input:
-
get_cached_context
- Input:
Required:{ "filePath": "path/to/file.ts", "cacheKey": "optional-key" }
filePath
. Optional:cacheKey
.
- Input:
-
analyze_code_diff
- Input:
{ "filePath": "path/to/file.ts", "oldContent": "export function a() { return 1 }", "newContent": "export function a() { return 2 }" }
- Input:
-
optimize_imports
- Input:
{ "filePath": "path/to/file.ts", "usedSymbols": ["useEffect", "useMemo"] }
- Input:
-
get_config
- Input (optional section):
Allowed sections:{ "section": "extraction" }
cache
,extraction
,imports
,diff
,performance
,languages
,logging
,security
.
- Input (optional section):
-
update_config
- Input:
{ "config": { "extraction": { "maxTokens": 2000 }, "cache": { "maxEntries": 1000, "ttlMs": 3600000 } } }
- Input:
-
reset_config
- No input.
Note: Tool results are returned as MCP content with a single text
item containing JSON of the result, e.g.
{
"content": [{ "type": "text", "text": "{\n \"...\": true\n}" }]
}
Examples
See docs/EXAMPLES.md
for end‑to‑end request examples of each tool.
Configuration
- Call
get_config
,update_config
,reset_config
to manage runtime settings. - You may also set environment variables via your MCP client if supported (e.g.,
LOG_LEVEL
).
Development
npm ci
npm run build
npm start # run built server (stdio)
npm run dev # tsc --watch
npm test
npm run lint
npm run type-check
Publishing (maintainers)
npm login
npm run clean && npm run build
npm version patch
npm publish --access public
License
MIT — see LICENSE
.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.