MCP Server Management
This guide covers managing MCP servers in Cosine CLI, troubleshooting common issues, and building custom servers.
Using MCP Tools
Section titled “Using MCP Tools”Once configured, MCP tools appear as available tools in Cosine. The AI will:
- Discover tools automatically when starting a session
- Suggest relevant tools based on your requests
- Request approval before executing tools (unless auto-accept is enabled)
Example Interactions
Section titled “Example Interactions”File System Operations:
You: Read the README.md file in my documents folderCosine: I'll read that file for you. [Uses mcp_filesystem tool]Database Queries:
You: What tables are in my postgres database?Cosine: Let me check the database schema. [Uses mcp_postgres tool]GitHub Operations:
You: Create an issue titled "Bug in login flow" in my repoCosine: I'll create that issue. [Uses mcp_github tool]Security Considerations
Section titled “Security Considerations”Tool Approval
Section titled “Tool Approval”By default, Cosine asks for your approval before executing any MCP tool. You can see:
- Which tool is being called
- What arguments are being passed
- The expected outcome
To auto-accept all tool executions (use with caution):
cos start --auto-acceptEnvironment Variables
Section titled “Environment Variables”For sensitive data like API keys:
- Store them in the
envfield of your MCP config - Consider using environment variable references
- Never commit
mcp.jsonwith secrets to version control
{ "mcpServers": { "api": { "transport": "stdio", "command": "node", "args": ["/path/to/server.js"], "env": { "API_KEY": "${MY_API_KEY}" } } }}Scope of Access
Section titled “Scope of Access”Each MCP server only has access to what you configure:
- File system servers: Only see directories you specify
- API servers: Only have permissions of the tokens you provide
- Database servers: Only access to the connection string you configure
Popular MCP Servers
Section titled “Popular MCP Servers”Here’s a list of official and community MCP servers you can use:
Official Anthropic Servers
Section titled “Official Anthropic Servers”| Server | Install Command | Description |
|---|---|---|
| Filesystem | npx -y @modelcontextprotocol/server-filesystem /path | Read/write files in allowed directories |
| GitHub | npx -y @modelcontextprotocol/server-github | Repository operations, issues, PRs |
| Git | npx -y @modelcontextprotocol/server-git | Git operations on local repos |
| PostgreSQL | npx -y @modelcontextprotocol/server-postgres <connection> | Database queries |
| SQLite | npx -y @modelcontextprotocol/server-sqlite <db> | SQLite database access |
| Slack | npx -y @modelcontextprotocol/server-slack | Send messages, channel operations |
| Brave Search | npx -y @modelcontextprotocol/server-brave-search | Web search via Brave API |
| Fetch | npx -y @modelcontextprotocol/server-fetch | HTTP requests to any URL |
| Puppeteer | npx -y @modelcontextprotocol/server-puppeteer | Browser automation |
Community Servers
Section titled “Community Servers”For more MCP servers from the community, visit the MCP Servers Repository.
Troubleshooting
Section titled “Troubleshooting”Server Not Appearing
Section titled “Server Not Appearing”If an MCP server doesn’t appear in the tool list:
- Check the server is properly configured in
~/.cosine/mcp.json - Verify the command is installed and available in your PATH
- Check for JSON syntax errors in the config file
- Try restarting Cosine
Connection Errors
Section titled “Connection Errors”If you see connection errors:
- Verify the server URL (for HTTP transport) is correct and accessible
- Check that required environment variables are set
- For stdio servers, test the command manually in your terminal
Tool Execution Failures
Section titled “Tool Execution Failures”If tools fail to execute:
- Check the Cosine output for error messages
- Verify the MCP server has the necessary permissions
- Review the server’s documentation for configuration requirements
Building Custom MCP Servers
Section titled “Building Custom MCP Servers”You can build your own MCP servers to integrate proprietary tools or custom APIs. MCP servers can be built in any language and communicate via the standard MCP protocol.
Resources for Building Servers
Section titled “Resources for Building Servers”Quick Example (Python)
Section titled “Quick Example (Python)”from mcp.server import Serverfrom mcp.types import TextContent
app = Server("my-server")
@app.tool()def search_docs(query: str) -> str: """Search documentation for a query.""" # Your implementation here return f"Results for: {query}"
if __name__ == "__main__": app.run()Quick Example (TypeScript)
Section titled “Quick Example (TypeScript)”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(CallToolRequestSchema, async (request) => { if (request.params.name === 'search_docs') { const { query } = request.params.arguments; return { content: [{ type: 'text', text: `Results for: ${query}` }], }; } throw new Error('Tool not found');});
const transport = new StdioServerTransport();await server.connect(transport);Next Steps
Section titled “Next Steps”- MCP Configuration - Learn about MCP configuration basics
- MCP Examples - See example configurations for popular MCP servers
- Configuration - Learn about general CLI configuration