Skip to content

MCP Server Management

This guide covers managing MCP servers in Cosine CLI, troubleshooting common issues, and building custom servers.

Once configured, MCP tools appear as available tools in Cosine. The AI will:

  1. Discover tools automatically when starting a session
  2. Suggest relevant tools based on your requests
  3. Request approval before executing tools (unless auto-accept is enabled)

File System Operations:

You: Read the README.md file in my documents folder
Cosine: 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 repo
Cosine: I'll create that issue. [Uses mcp_github tool]

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):

Terminal window
cos start --auto-accept

For sensitive data like API keys:

  • Store them in the env field of your MCP config
  • Consider using environment variable references
  • Never commit mcp.json with secrets to version control
{
"mcpServers": {
"api": {
"transport": "stdio",
"command": "node",
"args": ["/path/to/server.js"],
"env": {
"API_KEY": "${MY_API_KEY}"
}
}
}
}

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

Here’s a list of official and community MCP servers you can use:

ServerInstall CommandDescription
Filesystemnpx -y @modelcontextprotocol/server-filesystem /pathRead/write files in allowed directories
GitHubnpx -y @modelcontextprotocol/server-githubRepository operations, issues, PRs
Gitnpx -y @modelcontextprotocol/server-gitGit operations on local repos
PostgreSQLnpx -y @modelcontextprotocol/server-postgres <connection>Database queries
SQLitenpx -y @modelcontextprotocol/server-sqlite <db>SQLite database access
Slacknpx -y @modelcontextprotocol/server-slackSend messages, channel operations
Brave Searchnpx -y @modelcontextprotocol/server-brave-searchWeb search via Brave API
Fetchnpx -y @modelcontextprotocol/server-fetchHTTP requests to any URL
Puppeteernpx -y @modelcontextprotocol/server-puppeteerBrowser automation

For more MCP servers from the community, visit the MCP Servers Repository.

If an MCP server doesn’t appear in the tool list:

  1. Check the server is properly configured in ~/.cosine/mcp.json
  2. Verify the command is installed and available in your PATH
  3. Check for JSON syntax errors in the config file
  4. Try restarting Cosine

If you see connection errors:

  1. Verify the server URL (for HTTP transport) is correct and accessible
  2. Check that required environment variables are set
  3. For stdio servers, test the command manually in your terminal

If tools fail to execute:

  1. Check the Cosine output for error messages
  2. Verify the MCP server has the necessary permissions
  3. Review the server’s documentation for configuration requirements

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.

from mcp.server import Server
from 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()
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);