MCP Server Quick Start Guide
What is MCP?
The Model Context Protocol (MCP) is an open standard that allows Large Language Models (LLMs) like GitHub Copilot to interact with external systems and APIs in a standardized way. This integration exposes your Baldr API capabilities to LLMs directly in VS Code.
Quick Start
1. Build the Project
npm run build
2. Configure VS Code MCP Server
Your MCP server is already configured in .vscode/mcp.json:
{
"servers": {
"BaldrApi": {
"type": "stdio",
"command": "node",
"args": [
"/home/romain/Dev/projects/BaldrTs/dist/mcp-server.js"
],
"env": {
"NODE_ENV": "development"
}
}
},
"inputs": []
}
✅ This configuration is ready to use! The MCP server will automatically start when you interact with Copilot.
3. Using with GitHub Copilot in VS Code
- Open Copilot Chat (Ctrl+Shift+I or Cmd+Shift+I)
- Use the @ symbol to access MCP tools:
@BaldrApi - Ask questions about your API:
Example prompts:
"@BaldrApi check the health of the Baldr API"
"@BaldrApi list all available modules"
"@BaldrApi what tools are available?"
4. Test the Connection (Optional)
You can manually test the MCP server:
npm run mcp:test
HTTP Testing Interface
While the MCP server primarily uses stdio transport, you can also test it via HTTP:
# Check server status
curl http://localhost:3000/api/mcp/status
# Get server info
curl http://localhost:3000/api/mcp/info
# List tools (requires authentication)
curl http://localhost:3000/api/mcp/tools \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Available Tools
Out of the box, these tools are available:
- get_api_health - Check API health status
- list_modules - List all available modules
- query_collection - Query MongoDB collections
- get_api_stats - Get API usage statistics
Customizing Tools
Adding a New Tool
Edit src/configs/mcp.config.ts and add:
mcpService.registerTool(
"my_tool_name",
"Description of what this tool does",
{
type: "object",
properties: {
parameter1: {
type: "string",
description: "What this parameter does",
},
},
required: ["parameter1"],
},
async (args) => {
// Your implementation here
return { result: "success" };
}
);
Using Real API Operations
See src/configs/mcp.advanced.config.ts for examples of integrating with:
- User management
- Product queries
- Order processing
- Analytics
- Module management
To enable advanced tools, uncomment the relevant sections and import into mcp-server.ts.
Troubleshooting
MCP Server Not Available in VS Code
- Verify
.vscode/mcp.jsonexists and is properly formatted - Check that
npm run buildcompleted successfully - Ensure
dist/mcp-server.jsexists - Reload VS Code window (Ctrl+Shift+P → "Developer: Reload Window")
Connection Errors
- Check that environment variables are set in your
.envfile - Verify database connection is working
- Check VS Code Developer Tools for MCP-related errors (Help → Toggle Developer Tools)
- Make sure MongoDB is running
Tools Not Executing
- Check that the tool is registered in
mcp.config.ts - Verify your implementation doesn't have errors
- Look for error messages in the server logs
Build Fails
# Clean build
npm run build
# Check for TypeScript errors
npx tsc --noEmit
Environment Variables
Make sure your .env file includes:
NODE_ENV=development
PORT=3000
MONGODB_URI=mongodb://localhost:27017/your_database
# ... other required variables
Security Notes
- Authentication: HTTP endpoints can use your existing auth middleware
- Stdio Transport: The MCP server uses stdio (stdin/stdout), which is secure for local/trusted environments
- Tool Permissions: Consider which operations should be exposed via MCP
- Logging: All operations are logged via Pino
Next Steps
- ✅ Build the project with
npm run build - ✅ Verify
.vscode/mcp.jsonconfiguration - ✅ Open Copilot Chat and use
@BaldrApi - ✅ Test tools with Copilot
- 📝 Customize tools for your specific needs
- 📝 Implement real API operations in tools
- 📝 Add authentication/authorization as needed
Resources
- MCP Specification
- MCP SDK Documentation
- VS Code MCP Documentation
- Full documentation:
documents/MCP_INTEGRATION.md
Example Conversations with GitHub Copilot
Once configured, you can have conversations in VS Code like:
You: "@BaldrApi What's the status of the Baldr API?"
Copilot: Uses get_api_health tool and reports the status
You: "@BaldrApi Can you list all active modules?"
Copilot: Uses list_modules tool with includeInactive=false
You: "@BaldrApi Query the users collection"
Copilot: Uses query_collection tool with appropriate parameters
Enjoy using your API with GitHub Copilot in VS Code! 🎉