Code Reference Optimizer MCP Server

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.

Category
Visit Server

README

Code Reference Optimizer MCP Server

npm version node version license

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:
      {
        "filePath": "path/to/file.ts",
        "targetSymbols": ["myFunc", "MyClass"],
        "includeImports": true,
        "maxTokens": 1000
      }
      
      Required: filePath. Optional: targetSymbols, includeImports (default true), maxTokens (default 1000).
  • get_cached_context

    • Input:
      { "filePath": "path/to/file.ts", "cacheKey": "optional-key" }
      
      Required: filePath. Optional: cacheKey.
  • analyze_code_diff

    • Input:
      {
        "filePath": "path/to/file.ts",
        "oldContent": "export function a() { return 1 }",
        "newContent": "export function a() { return 2 }"
      }
      
  • optimize_imports

    • Input:
      { "filePath": "path/to/file.ts", "usedSymbols": ["useEffect", "useMemo"] }
      
  • get_config

    • Input (optional section):
      { "section": "extraction" }
      
      Allowed sections: cache, extraction, imports, diff, performance, languages, logging, security.
  • update_config

    • Input:
      {
        "config": {
          "extraction": { "maxTokens": 2000 },
          "cache": { "maxEntries": 1000, "ttlMs": 3600000 }
        }
      }
      
  • 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

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured