Skip to content

MCP Configuration

Model Context Protocol (MCP) allows Sidian to connect to external tools and services, extending the AI's capabilities beyond code editing. This guide covers how to configure and manage MCP servers.

What is MCP?

MCP is a standardized protocol that allows AI assistants to securely connect to external tools and data sources:

Capabilities

  • File system operations
  • Git repository management
  • Database queries
  • API integrations
  • Memory and context storage

Benefits

  • Secure sandboxed execution
  • Standardized protocol
  • Extensible architecture
  • Community-driven servers
  • Easy configuration

Configuration Location

Sidian reads MCP configuration from the following location:

Configuration File

  • Windows: C:\Users\{YourUsername}\.sidian\mcp.json
  • macOS: ~/.sidian/mcp.json
  • Linux: ~/.sidian/mcp.json

Basic Configuration

The MCP configuration file uses JSON format with the following structure:

json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/your/workspace"],
      "env": {}
    },
    "git": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-git", "--repository", "/path/to/your/git/repository"],
      "env": {}
    },
    "memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"],
      "env": {}
    }
  }
}

Here are some commonly used MCP servers and their configurations:

Filesystem Server

Provides file system access for reading, writing, and managing files:

json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/your/workspace"],
      "env": {}
    }
  }
}

Git Server

Enables Git operations and repository management:

json
{
  "mcpServers": {
    "git": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-git", "--repository", "/path/to/your/git/repo"],
      "env": {}
    }
  }
}

Memory Server

Provides persistent memory for AI conversations:

json
{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"],
      "env": {}
    }
  }
}

Database Server

Connects to databases for queries and operations:

json
{
  "mcpServers": {
    "brave-search": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-brave-search"],
      "env": {
        "BRAVE_API_KEY": "your-brave-api-key-here"
      }
    }
  }
}

Advanced Configuration

Environment Variables

Set environment variables for MCP servers:

json
{
  "mcpServers": {
    "custom-server": {
      "command": "node",
      "args": ["/path/to/custom-server.js"],
      "env": {
        "API_KEY": "your-api-key",
        "DEBUG": "true",
        "TIMEOUT": "30000"
      }
    }
  }
}

Server Options

Configure server-specific options:

json
{
  "mcpServers": {
    "web-server": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-web"],
      "options": {
        "timeout": 30000,
        "retries": 3,
        "logLevel": "info"
      }
    }
  }
}

Conditional Configuration

Use different configurations based on environment:

json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "        "${SIDIAN_PROJECT_ROOT:-/default/path}""
      ]
    }
  }
}

Security Considerations

Sandboxing

  • MCP servers run in isolated processes
  • Limited access to system resources
  • Configurable permission boundaries
  • Audit logging for all operations

Access Control

  • Whitelist allowed directories and files
  • Restrict network access
  • Limit command execution
  • Monitor resource usage

Best Practices

  • Use minimal required permissions
  • Regularly update MCP server packages
  • Monitor server logs for suspicious activity
  • Use environment variables for sensitive data

Troubleshooting

Server Won't Start

  • Check if Node.js is installed and accessible
  • Verify the server package is installed: npm list -g
  • Check the MCP configuration file syntax
  • Look at server logs for specific error messages
  • Try manually running the server command in terminal

Permission Errors

  • Ensure Sidian has read/write access to configured directories
  • Check file system permissions on project folders
  • Run Sidian as administrator if necessary (Windows)
  • Verify the MCP configuration file is readable

Server Keeps Crashing

  • Update the MCP server package to latest version
  • Check for conflicting Node.js versions
  • Increase timeout values in configuration
  • Monitor system resources (CPU, memory)
  • Check server logs for error patterns

Performance Issues

  • Reduce the number of active MCP servers
  • Optimize server configurations
  • Use local servers instead of remote ones
  • Monitor network latency for remote servers
  • Consider caching strategies

Custom MCP Servers

Creating Custom Servers

You can create custom MCP servers for specific needs:

javascript
// custom-server.js
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');

const server = new Server({
  name: 'custom-server',
  version: '1.0.0'
});

// Add your custom tools and resources here
server.setRequestHandler('tools/list', async () => {
  return {
    tools: [
      {
        name: 'custom-tool',
        description: 'A custom tool for specific operations',
        inputSchema: {
          type: 'object',
          properties: {
            input: { type: 'string' }
          }
        }
      }
    ]
  };
});

const transport = new StdioServerTransport();
server.connect(transport);

Configuration for Custom Server

json
{
  "mcpServers": {
    "custom": {
      "command": "node",
      "args": ["/path/to/custom-server.js"]
    }
  }
}

Monitoring and Logging

Server Status

Monitor MCP server status in Sidian:

  • Check server connection status in settings
  • View server logs in the output panel
  • Monitor resource usage
  • Track error rates and performance

Debugging

Enable debug logging for troubleshooting:

json
{
  "mcpServers": {
    "debug-server": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"],
      "env": {
        "DEBUG": "*",
        "LOG_LEVEL": "debug"
      }
    }
  }
}

MCP configuration allows you to extend Sidian's AI capabilities significantly. Start with basic servers and gradually add more complex configurations as needed.