-
Notifications
You must be signed in to change notification settings - Fork 7
PoC: local MCP Server with search_docs tool #538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
9kubczas4
wants to merge
17
commits into
synergycodes:main
Choose a base branch
from
9kubczas4:poc/mcp-search-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add .kiro directory to gitignore to exclude Kiro-related temporary files - Prevent accidental commits of Kiro build artifacts and cache files - Keep repository clean from tool-specific generated files
- Add search_docs tool handler with SearchEngine integration - Create tool configuration with MCP schema definition - Define TypeScript interfaces for SearchDocsInput and SearchDocsOutput - Implement input validation for query and limit parameters - Add comprehensive unit tests covering tool schema and handler behavior - Export public API through index file for tool integration - Enables documentation search capability through MCP protocol
- Remove JSDoc comments from class and method definitions - Remove inline comments explaining obvious code functionality - Delete .gitkeep placeholder files from src and tests directories - Simplify index.ts by removing redundant comment lines - Clean up server.ts by removing block documentation comments - Streamline services (indexer.ts, search.ts) by removing verbose documentation - Improve code readability by keeping only essential comments - Maintain all functionality while reducing comment clutter
- Remove test:coverage script from package.json - Remove coverage testing instructions from README.md - Remove testing coverage target from standards documentation - Simplify testing documentation to focus on essential commands
- Add exact phrase matching as highest priority search level - Implement multi-word matching requiring 50% word match threshold - Add single-word matching as fallback with noise filtering for words < 3 chars - Refactor matchDocument into three specialized private methods for clarity - Improve excerpt extraction to find first query word when exact phrase not found - Update search_docs tool description with usage examples and query guidance - Adjust test expectations to accommodate multiple matching results - Enhance search relevance by scoring partial matches at 80% and single-word matches at 50% of exact match scorese
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ng-diagram MCP Server
An MCP (Model Context Protocol) server that provides intelligent documentation search for the ng-diagram library. Connect it to AI assistants like Claude, Cursor, or any MCP-compatible tool to get instant access to ng-diagram documentation.
What is This?
This server allows AI assistants to search through ng-diagram's documentation and return relevant results with direct links. Instead of manually browsing docs, you can ask your AI assistant questions like:
The AI will search the documentation and provide you with relevant pages and direct links.
How It Works
graph LR A[AI Assistant] -->|1. Search Query| B[MCP Server] B -->|2. Returns URLs| A A -->|3. Read Resource| B B -->|4. Returns Content| A A -->|5. Answers with Context| D[User]Flow:
search_docstoolKey Benefit: The AI can now read the actual documentation content, not just see URLs!
Current Usage (Internal)
Who can use it now: ng-diagram maintainers and contributors
This server is currently configured to run locally for the ng-diagram development team. It indexes the documentation from the monorepo and provides search capabilities during development.
Setup for Development
Install dependencies:
cd tools/mcp-server pnpm installBuild the server:
Configure your MCP client (e.g., Claude Desktop, Cursor, Kiro):
Add to your MCP configuration file:
{ "mcpServers": { "ng-diagram-docs": { "command": "node", "args": ["/absolute/path/to/ng-diagram/tools/mcp-server/dist/index.js"], "cwd": "/absolute/path/to/ng-diagram" } } }Restart your AI assistant to load the server
Test it: Ask your AI assistant to search ng-diagram documentation!
Future Vision (Public Release)
For Library Consumers
In the future, ng-diagram users will be able to install and use this MCP server without cloning the repository:
Then configure it in your AI assistant to get instant documentation access while building your Angular diagrams.
Roadmap
Phase 1: MVP (Current) ✅
Phase 2: Enhanced Search
Phase 3: Public Distribution
Phase 4: Advanced Features
API Reference
Tool:
search_docsSearch through ng-diagram documentation.
Parameters:
query(string, required): Search querylimit(number, optional): Max results to return (default: 10)Response:
Example:
{ "query": "custom nodes", "limit": 3 }Returns:
{ "results": [ { "title": "Custom Nodes", "description": "How to create and implement custom nodes in ngDiagram", "excerpt": "...create custom node components with any Angular template...", "url": "https://www.ngdiagram.dev/docs/guides/nodes/custom-nodes" } ] }Resources API
The server exposes all indexed documentation as MCP Resources, allowing AI assistants to read the full content of documentation pages.
List Resources:
resources/listLists all available documentation resources.
Response:
Example Response:
{ "resources": [ { "uri": "https://www.ngdiagram.dev/docs/guides/nodes/custom-nodes", "name": "Custom Nodes", "description": "How to create and implement custom nodes in ngDiagram", "mimeType": "text/plain" }, { "uri": "https://www.ngdiagram.dev/docs/intro/quick-start", "name": "Quick Start", "description": "Get started with ng-diagram in minutes", "mimeType": "text/plain" } ] }Read Resource:
resources/readReads the full content of a specific documentation page.
Parameters:
uri(string, required): The full URL of the documentation pageResponse:
Example Request:
{ "uri": "https://www.ngdiagram.dev/docs/guides/nodes/custom-nodes" }Example Response:
{ "contents": [ { "uri": "https://www.ngdiagram.dev/docs/guides/nodes/custom-nodes", "mimeType": "text/plain", "text": "# Custom Nodes\n\nYou can create custom node components..." } ] }Usage Pattern:
search_docstoolresources/readwith the URLThis two-step approach ensures the AI has access to complete documentation context when answering questions.
Development
Project Structure
Commands
Architecture
graph TD A[MCP Client] -->|stdio| B[MCP Server] B --> C[Documentation Indexer] B --> D[Search Engine] C -->|Scans| E[Markdown Files] C -->|Extracts| F[Frontmatter] C -->|Builds| G[In-Memory Index] D -->|Queries| G D -->|Ranks| H[Search Results] H -->|Returns| BComponents:
.md/.mdxfiles, extracts metadataContributing
This is part of the ng-diagram monorepo. Contributions are welcome!
tools/mcp-server/pnpm testpnpm buildLicense
PoC implemented by Pawel Kubiak
MIT - Part of the ng-diagram project
Built with ❤️ by the Synergy Codes team