MCP Integration in PS Smart Agent
The Model Context Protocol (MCP) allows you to extend PS Smart Agent with external tools, databases, and APIs. This guide shows you how to set up and use MCP servers.
What is MCP?
MCP is a protocol that enables AI assistants to:
- Connect to external data sources
- Execute custom tools
- Access databases
- Integrate with APIs
- Extend functionality
Setting Up MCP Servers
1. Open MCP Settings
- Click the MCP icon in the toolbar
- Or go to Settings > MCP
2. Add a Server
Click “Add Server” and configure:
{
"name": "my-server",
"command": "node",
"args": ["path/to/server.js"],
"env": {
"API_KEY": "your-key"
}
}
Popular MCP Servers
Filesystem Server
Access files outside your workspace:
{
"name": "filesystem",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/files"]
}
PostgreSQL Server
Connect to PostgreSQL databases:
{
"name": "postgres",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"POSTGRES_URL": "postgresql://user:pass@localhost/db"
}
}
GitHub Server
Interact with GitHub:
{
"name": "github",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "your-token"
}
}
Brave Search Server
Web search capabilities:
{
"name": "brave-search",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
"env": {
"BRAVE_API_KEY": "your-key"
}
}
Using MCP Tools
Once configured, MCP tools appear in PS Smart Agent:
- Type
@in the chat - Select the MCP tool
- Provide the required parameters
Creating Custom MCP Servers
Basic Server Structure
import { Server } from '@modelcontextprotocol/sdk';
const server = new Server({
name: 'my-custom-server',
version: '1.0.0'
});
// Add tools
server.addTool({
name: 'my_tool',
description: 'Does something useful',
parameters: {
type: 'object',
properties: {
input: { type: 'string' }
}
},
handler: async (params) => {
return { result: `Processed: ${params.input}` };
}
});
server.start();
Troubleshooting MCP
Server Not Starting
- Check the command path
- Verify environment variables
- Check server logs in MCP view
Tools Not Appearing
- Restart the MCP server
- Check server configuration
- Verify tool definitions
Learn more at pyshine.com