MCP Integration¶
Extend Dial Code with external tools via the Model Context Protocol.
What is MCP?¶
The Model Context Protocol (MCP) is a standard for connecting AI assistants to external tools and data sources.
With MCP, you can:
- Add database access
- Connect to APIs
- Use specialized tools
- Share tools across projects
Quick Start¶
Add an MCP server to your settings:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/path/to/allowed/dir"
]
}
}
}
Configuration¶
Basic Server¶
With Environment Variables¶
{
"mcpServers": {
"github": {
"command": "mcp-server-github",
"env": {
"GITHUB_TOKEN": "ghp_..."
}
}
}
}
Trust Settings¶
Transport Types¶
stdio (Default)¶
Server communicates via stdin/stdout:
SSE (Server-Sent Events)¶
For HTTP-based servers:
Popular MCP Servers¶
Filesystem¶
Access files in specific directories:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/home/user/documents"
]
}
}
}
GitHub¶
Interact with GitHub repositories:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "ghp_..."
}
}
}
}
PostgreSQL¶
Query PostgreSQL databases:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgresql://user:pass@localhost/db"
}
}
}
}
Brave Search¶
Web search via Brave:
{
"mcpServers": {
"brave-search": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
"env": {
"BRAVE_API_KEY": "..."
}
}
}
}
Managing Servers¶
View Status¶
Shows:
- Connected servers
- Available tools from each
- Connection status
Tool Filtering¶
Include only specific tools:
Exclude tools:
Creating MCP Servers¶
Node.js Example¶
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const server = new Server(
{
name: 'my-server',
version: '1.0.0',
},
{
capabilities: {
tools: {},
},
},
);
server.setRequestHandler('tools/list', async () => ({
tools: [
{
name: 'my_tool',
description: 'Does something useful',
inputSchema: {
type: 'object',
properties: {
input: { type: 'string' },
},
},
},
],
}));
server.setRequestHandler('tools/call', async (request) => {
if (request.params.name === 'my_tool') {
return {
content: [{ type: 'text', text: 'Result' }],
};
}
});
const transport = new StdioServerTransport();
await server.connect(transport);
Python Example¶
from mcp.server import Server
from mcp.server.stdio import stdio_server
server = Server("my-server")
@server.list_tools()
async def list_tools():
return [{
"name": "my_tool",
"description": "Does something useful",
"inputSchema": {
"type": "object",
"properties": {
"input": {"type": "string"}
}
}
}]
@server.call_tool()
async def call_tool(name: str, arguments: dict):
if name == "my_tool":
return {"content": [{"type": "text", "text": "Result"}]}
async def main():
async with stdio_server() as (read, write):
await server.run(read, write)
Troubleshooting¶
"Server Not Connected"¶
- Check the command path
- Verify the server is installed
- Check for error output
"Tool Not Found"¶
- Verify server provides the tool
- Check
includeTools/excludeTools - Run
/mcpto see available tools
Environment Variables¶
Ensure env vars are set correctly:
Resources¶
Next Steps¶
- File System - Built-in file tools
- Shell - Command execution