MCP Integration
Connect any Model Context Protocol server to Misar Code — MCP tools are merged with built-in tools and made available to the agent transparently.
Overview
Misar Code supports the Model Context Protocol (MCP), an open standard for connecting AI agents to external tools and data sources. Configure MCP servers once in .misar/mcp.json and their tools become available alongside built-in tools in every session.
Configuration
Create .misar/mcp.json in your workspace root:
{
"servers": [
{
"name": "filesystem",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
"transport": "stdio"
},
{
"name": "postgres",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"],
"transport": "stdio"
},
{
"name": "github",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"transport": "stdio",
"env": {
"GITHUB_TOKEN": "${env:GITHUB_TOKEN}"
}
}
]
}
The extension discovers this file on activation and registers all listed servers.
Only stdio transport is supported. Each server process is spawned as a child process of the extension host.
How It Works
Discovery — on activation the extension reads .misar/mcp.json and spawns each server process.
Tool registration — the extension calls each server's tools/list method and merges the returned schemas with the built-in tool list.
Transparent use — the agent sees all tools (built-in + MCP) in a single flat list. It calls MCP tools the same way it calls built-in ones.
Execution — when the agent requests an MCP tool, the extension routes the call to the correct server process via stdio and returns the result.
MCP Management API
The backend exposes a REST API for managing MCP servers programmatically:
Configure Servers
POST /mcp/configure
Content-Type: application/json
{
"servers": [
{
"name": "my-server",
"command": "node",
"args": ["./my-mcp-server.js"],
"transport": "stdio"
}
]
}
List Active Servers
GET /mcp/servers
{
"servers": [
{ "name": "filesystem", "status": "running", "tool_count": 5 },
{ "name": "postgres", "status": "running", "tool_count": 8 }
]
}
List Available Tools
GET /mcp/tools
Returns all tools across all connected servers with their full JSON Schema definitions.
Invoke a Tool
POST /mcp/call
Content-Type: application/json
{
"server": "postgres",
"tool": "query",
"arguments": {
"sql": "SELECT count(*) FROM users"
}
}
Disconnect a Server
POST /mcp/remove
Content-Type: application/json
{ "name": "filesystem" }
Popular MCP Servers
Filesystem
Read and write files outside the current workspace. Install: @modelcontextprotocol/server-filesystem
PostgreSQL
Run queries and inspect schema on a live database. Install: @modelcontextprotocol/server-postgres
GitHub
Search code, manage issues, and read PRs via the GitHub API. Install: @modelcontextprotocol/server-github
Brave Search
Web search capability for the agent. Install: @modelcontextprotocol/server-brave-search
Environment Variable Interpolation
Use ${env:VAR_NAME} in the env block to pull values from the host environment without hardcoding secrets in mcp.json:
{
"env": {
"API_KEY": "${env:MY_API_KEY}",
"DATABASE_URL": "${env:DATABASE_URL}"
}
}
Never commit API keys or secrets directly in mcp.json. Always use ${env:...} interpolation and store secrets in your shell environment or a .env file that is gitignored.
Troubleshooting
| Symptom | Likely Cause | Fix |
|---------|-------------|-----|
| Server not appearing in tool list | Process failed to start | Check Output panel → Misar Code for stderr from the server process |
| Tool call returns an error | Wrong arguments or server-side error | Check the server's own logs; test with POST /mcp/call directly |
| Server keeps restarting | Command not found or missing dependency | Verify the command is on $PATH; run it manually in a terminal first |