MCP server for ResearchSpace code documentation and exploration. Ask questions about the codebase and get accurate answers with file references.
npm install @gspinaci/rs-code-docs-mcpA Model Context Protocol (MCP) server that helps you understand and navigate the ResearchSpace codebase. Ask questions about the code and get accurate answers with direct file references.
This MCP server is designed to help developers understand the ResearchSpace codebase by:
- Answering questions about code structure and implementation
- Finding relevant code sections based on natural language queries
- Providing direct file references and code snippets
- Helping locate where specific functionality is implemented
- "How can I modify the Field Definitions?"
- "How can I create a field?"
- "Where does the parsing of a query happen?"
- "How is authentication implemented?"
- "Where are the SPARQL queries defined?"
This MCP server provides tools for code documentation and exploration:
#### 1. rs_ping
Returns the server version and operational status.
Parameters: None
Returns:
``json`
{
"version": "1.0.0",
"status": "operational"
}
#### 2. rs_search
Searches the indexed repository using semantic search. Returns relevant code chunks with similarity scores and file references.
Parameters:
- query (string, required): Search query (natural language or keywords)k
- (number, optional): Number of results to return (default: 8)scope
- (string, optional): "repo", "docs", "apps", or "all" (default: "all")
Returns:
`json`
{
"hits": [
{
"id": "repo:src/main/java/org/researchspace/api/rest/client/FieldDefinition.java:0",
"source": "repo",
"filepath": "src/main/java/org/researchspace/api/rest/client/FieldDefinition.java",
"chunkId": 0,
"snippet": "public class FieldDefinition { ... }",
"score": 0.85,
"metadata": { ... }
}
],
"totalHits": 8
}
#### 3. rs_openrs_search
Opens and returns the full content of a specific search result chunk by its ID. Use this to get complete context after finding relevant code with .
Parameters:
- hitId (string, required): The ID of the search hit to open (from rs_search results)
Returns:
`json`
{
"success": true,
"content": "Full chunk content here...",
"metadata": {
"source": "repo",
"filepath": "src/main/java/org/researchspace/api/rest/client/FieldDefinition.java",
"chunkId": 0,
"totalChunks": 5
},
"message": "Chunk retrieved successfully"
}
The recommended workflow for answering code questions is: search → open → answer
1. Search: Use rs_search with a natural language query to find relevant coders_open
2. Open: Use to get full context of the most relevant results
3. Answer: Provide accurate answers with direct file references
Question: "How can I modify the Field Definitions?"
`javascript
// 1. Search for field definition code
rs_search({
query: "field definition modification create update",
k: 5,
scope: "repo"
})
// 2. Open the most relevant result
rs_open({
hitId: "repo:src/main/java/org/researchspace/api/rest/client/FieldDefinition.java:0"
})
// 3. Provide answer with file reference:
// "Field definitions can be modified in the FieldDefinition.java class located at
// src/main/java/org/researchspace/api/rest/client/FieldDefinition.java..."
`
`bash`
npm install
Before first use, run the setup script to prepare the system:
`bash`
npm run setup
This will:
1. Clone the repository: Downloads https://github.com/researchspace/researchspace to ~/.cache/rs-mcp/researchspace/ (~500MB-1GB)
2. Build the vector index: Processes all files, creates chunks, and generates embeddings
Time estimate: 10-20 minutes total
- Repository clone: 2-5 minutes (depending on internet speed)
- Initial indexing: 5-15 minutes (depending on CPU)
Note: The embedding model (~90MB) will be downloaded automatically during indexing.
To refresh the index with the latest ResearchSpace code changes, simply re-run the setup:
`bash`
npm run setup
This will pull the latest changes from the repository and rebuild the index.
`bash`
npm run build
`bash`
npm start
`bash`
npm run dev
``
/src
server.ts # Main MCP server implementation
setup.ts # Setup script for repository and indexing
rag/ # RAG implementation (vector DB, indexing, search)
/tests # Test files
README.md
LICENSE
Add this server to your MCP client configuration:
`json`
{
"mcpServers": {
"rs-code-docs": {
"command": "node",
"args": ["/path/to/rs_app_builder_mcp/dist/server.js"]
}
}
}
javascript
rs_search({
query: "How can I modify the Field Definitions?",
k: 5,
scope: "repo"
})
`$3
`javascript
rs_search({
query: "How can I create a field?",
k: 5,
scope: "repo"
})
`$3
`javascript
rs_search({
query: "Where does the parsing of a query happen?",
k: 5,
scope: "repo"
})
``- MCP SDK: Model Context Protocol implementation
- Vectra: Local vector database for embeddings
- Xenova Transformers: all-MiniLM-L6-v2 model for text embeddings
- TypeScript: Type-safe implementation
MIT