{"id":31563387,"url":"https://github.com/fosterg4/mcpsaver","last_synced_at":"2025-10-05T04:58:55.315Z","repository":{"id":311109854,"uuid":"1042501818","full_name":"FosterG4/mcpsaver","owner":"FosterG4","description":"An MCP (Model Context Protocol) server that extracts minimal, relevant code context, analyzes diffs, and optimizes imports to reduce token usage for AI assistants.","archived":false,"fork":false,"pushed_at":"2025-08-22T06:29:49.000Z","size":83,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-22T07:32:12.104Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FosterG4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-22T05:50:50.000Z","updated_at":"2025-08-22T06:29:49.000Z","dependencies_parsed_at":"2025-08-22T07:32:15.057Z","dependency_job_id":"489fc1d6-8c59-40b4-bd22-ab4c9de7d1c7","html_url":"https://github.com/FosterG4/mcpsaver","commit_stats":null,"previous_names":["fosterg4/mcpsaver"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/FosterG4/mcpsaver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FosterG4%2Fmcpsaver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FosterG4%2Fmcpsaver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FosterG4%2Fmcpsaver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FosterG4%2Fmcpsaver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FosterG4","download_url":"https://codeload.github.com/FosterG4/mcpsaver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FosterG4%2Fmcpsaver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278411255,"owners_count":25982368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-05T04:58:52.057Z","updated_at":"2025-10-05T04:58:55.310Z","avatar_url":"https://github.com/FosterG4.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Code Reference Optimizer MCP Server\n\n[![Trust Score](https://archestra.ai/mcp-catalog/api/badge/quality/FosterG4/mcpsaver)](https://archestra.ai/mcp-catalog/fosterg4__mcpsaver)\n[![npm version](https://img.shields.io/npm/v/%40fosterg4%2Fmcpsaver.svg)](https://www.npmjs.com/package/@fosterg4/mcpsaver)\n![node version](https://img.shields.io/badge/node-%3E%3D18-brightgreen)\n![license](https://img.shields.io/badge/license-MIT-blue)\n\nAn advanced MCP (Model Context Protocol) server that intelligently extracts minimal, relevant code context using AST parsing, analyzes code differences, and optimizes imports to dramatically reduce token usage for AI assistants.\n\n## Key Features\n\n- **Smart Context Extraction**: Uses AST parsing to identify and extract only relevant code sections\n- **Multi-language Support**: TypeScript/JavaScript, Python, Go, Rust, Java, C++, and more\n- **Intelligent Caching**: LRU cache with configurable persistence and customizable storage paths\n- **Token Optimization**: Filters unnecessary code while maintaining semantic completeness\n- **Diff Analysis**: Provides minimal, focused code differences with semantic understanding\n- **Import Optimization**: Eliminates unused imports and suggests consolidation opportunities\n- **Configurable**: Runtime configuration via tools with persistent settings\n- **Simple Integration**: stdio-based server and optional HTTP server, easy to integrate with any MCP client\n\n## Quick Start (STDIO)\n\n- One-off (recommended):\n```bash\nnpx -y @fosterg4/mcpsaver\n```\nYou should see: `Code Reference Optimizer MCP server running on stdio`.\n\n- Global (optional):\n```bash\nnpm i -g @fosterg4/mcpsaver\nmcpsaver\n```\n\n## HTTP Mode\n\nStart the HTTP server on port 8081 (default):\n\n```bash\nnpx -y @fosterg4/mcpsaver mcpsaver-http\n# or after build\nnpm run start:http\n```\n\nConfigure your MCP client to use the HTTP binary if supported, e.g.:\n\n```json\n{\n  \"mcpServers\": {\n    \"mcpsaver\": { \"command\": \"mcpsaver-http\", \"env\": { \"PORT\": \"8081\", \"LOG_LEVEL\": \"info\" } }\n  }\n}\n```\n\n## Use with an MCP client\n\nAdd to your MCP client config (example `mcpServers.json`):\n```json\n{\n  \"mcpServers\": {\n    \"mcpsaver\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@fosterg4/mcpsaver\"],\n      \"env\": {}\n    }\n  }\n}\n```\n\n## Available Tools\n\nThe server provides 7 powerful tools for code analysis and optimization:\n\n### 🔍 `extract_code_context`\nExtracts minimal, focused code context using AST parsing. Intelligently identifies relevant code sections, imports, and dependencies for specific symbols.\n\n```json\n{\n  \"filePath\": \"path/to/file.ts\",\n  \"targetSymbols\": [\"myFunc\", \"MyClass\"],\n  \"includeImports\": true,\n  \"maxTokens\": 1000\n}\n```\n**Required**: `filePath` | **Optional**: `targetSymbols`, `includeImports`, `maxTokens`\n\n### 💾 `get_cached_context`\nRetrieves previously extracted and cached code context for fast access without re-parsing.\n\n```json\n{ \"filePath\": \"path/to/file.ts\", \"cacheKey\": \"optional-key\" }\n```\n**Required**: `filePath` | **Optional**: `cacheKey`\n\n### 📊 `analyze_code_diff`\nPerforms intelligent analysis of code differences with semantic understanding and minimal update suggestions.\n\n```json\n{\n  \"filePath\": \"path/to/file.ts\",\n  \"oldContent\": \"export function a() { return 1 }\",\n  \"newContent\": \"export function a() { return 2 }\"\n}\n```\n**Required**: `filePath`, `oldContent`, `newContent`\n\n### 🧹 `optimize_imports`\nAnalyzes and optimizes import statements to eliminate redundancy and improve code efficiency.\n\n```json\n{ \"filePath\": \"path/to/file.ts\", \"usedSymbols\": [\"useEffect\", \"useMemo\"] }\n```\n**Required**: `filePath` | **Optional**: `usedSymbols`\n\n### ⚙️ `get_config`\nRetrieves current configuration settings for cache behavior, extraction parameters, and more.\n\n```json\n{ \"section\": \"cache\" }\n```\n**Optional**: `section` (cache, extraction, imports, diff, performance, languages, logging, security)\n\n### 🔧 `update_config`\nUpdates configuration settings including cache policies, token limits, and performance thresholds.\n\n```json\n{\n  \"config\": {\n    \"cache\": { \"enablePersistence\": true, \"persistencePath\": \"/custom/cache/path\" },\n    \"extraction\": { \"maxTokens\": 2000 }\n  }\n}\n```\n**Required**: `config`\n\n### 🔄 `reset_config`\nResets all configuration settings to default values.\n\n```json\n{}\n```\n**No parameters required**\n\nNote: Tool results are returned as MCP content with a single `text` item containing JSON of the result, e.g.\n```json\n{\n  \"content\": [{ \"type\": \"text\", \"text\": \"{\\n  \\\"...\\\": true\\n}\" }]\n}\n```\n\n## Additional MCP Capabilities\n\n- **Prompts**: listed but empty; `get_prompt` returns MethodNotFound.\n- **Resources**: listed but empty; reading a resource returns MethodNotFound.\n- **Roots**: exposes the current working directory as a single root `workspace`.\n- **Sampling**: stubbed; `sampling/createMessage` returns MethodNotFound.\n\n## Examples\n\nSee `docs/EXAMPLES.md` for end‑to‑end request examples of each tool.\n\n## Configuration\n\n- Call `get_config`, `update_config`, `reset_config` to manage runtime settings.\n- You may also set environment variables via your MCP client if supported (e.g., `LOG_LEVEL`).\n\n### Structured Logging\n\nThe server uses a lightweight structured logger. Configure via `get_config`/`update_config` or env:\n\n- Level: `config.logging.level` (trace|debug|info|warn|error)\n- File logging: `config.logging.enableFileLogging` and `config.logging.logPath`\n\n## Development\n\n```bash\nnpm ci\nnpm run build\nnpm start     # run built server (stdio)\nnpm run start:http # run built server (http)\nnpm run dev   # tsc --watch\nnpm test\nnpm run lint\nnpm run type-check\n```\n\n## Publishing (maintainers)\n\n```bash\nnpm login\nnpm run clean \u0026\u0026 npm run build\nnpm version patch\nnpm publish --access public\n```\n\n## License\n\nMIT — see `LICENSE`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffosterg4%2Fmcpsaver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffosterg4%2Fmcpsaver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffosterg4%2Fmcpsaver/lists"}