Connect to Remote MCP Servers

Connect to Remote MCP Servers

Remote MCP servers extend AI capabilities beyond your local environment, providing access to internet-hosted tools, services, and data sources.

Understanding Remote Servers

Remote MCP servers are hosted on the internet rather than your local machine. They offer several advantages:

FeatureLocal ServersRemote Servers
AccessibilitySingle deviceAny device with internet
SetupInstall per deviceOne-time connection
MaintenanceManual updatesServer-side updates
Use CaseLocal resourcesCloud services, APIs

Connection Methods

Method 1: Claude Web (Custom Connectors)

The Claude web interface provides built-in support for remote MCP servers through Custom Connectors.

Steps to Connect

  1. Navigate to Settings

    • Go to claude.ai
    • Click your profile icon → Settings → Connectors
  2. Add Custom Connector

    • Scroll to “Add custom connector”
    • Enter the remote server URL
    • Click “Add”
  3. Complete Authentication

    • Follow the server’s authentication flow
    • May involve OAuth, API keys, or username/password
  4. Configure Permissions

    • Review available tools
    • Enable only the tools you need
    • Set appropriate usage limits

Method 2: Claude Desktop (SSE Transport)

For desktop applications, configure remote servers using Server-Sent Events transport:

{
  "mcpServers": {
    "remote-server": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/inspector",
        "https://your-server.example.com/sse"
      ]
    }
  }
}

Method 3: Custom Client Implementation

Build a custom MCP client that connects to remote servers:

from mcp.client.sse import SseClientTransport
from mcp import ClientSession

async def connect_to_remote(server_url: str):
    # Create SSE transport for remote connection
    transport = SseClientTransport(server_url)

    # Initialize session
    async with ClientSession(transport) as session:
        await session.initialize()

        # List available tools
        tools = await session.list_tools()
        return tools

Security Considerations

Verify Server Authenticity

Before connecting to any remote MCP server:

  1. Check the source: Only connect to servers from trusted developers
  2. Review the code: For open-source servers, review the implementation
  3. Check permissions: Understand what tools the server exposes
  4. Test in safe environment: Try non-sensitive operations first

Authentication Best Practices

Auth TypeUse CaseSecurity Level
API KeysSimple integrationsMedium
OAuth 2.0Third-party servicesHigh
JWT TokensEnterprise applicationsHigh
mTLSHigh-security environmentsVery High

Data Privacy

  • Review data handling: Understand what data the server processes
  • Check encryption: Ensure HTTPS/TLS is used
  • Audit logs: Monitor server activity
  • Set usage limits: Prevent excessive API calls

Common Remote Server Use Cases

Project Management Integration

Connect to services like Jira, Asana, or Linear:

{
  "mcpServers": {
    "jira": {
      "command": "node",
      "args": ["./jira-server/build/index.js"],
      "env": {
        "JIRA_URL": "https://your-domain.atlassian.net",
        "JIRA_EMAIL": "[email protected]",
        "JIRA_API_TOKEN": "your-api-token"
      }
    }
  }
}

Documentation Access

Connect to Confluence, Notion, or GitBook:

# Example: Notion MCP server connection
config = {
    "server_url": "https://notion-mcp.example.com",
    "auth": {
        "type": "bearer_token",
        "token": os.getenv("NOTION_INTEGRATION_TOKEN")
    }
}

Code Repository Integration

Connect to GitHub, GitLab, or Bitbucket:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_TOKEN": "your-github-token",
        "GITHUB_REPOSITORY": "owner/repo"
      }
    }
  }
}

Troubleshooting Remote Connections

Connection Failures

Symptoms: Server won’t connect or times out

Solutions:

  1. Verify the server URL is correct and accessible
  2. Check network connectivity and firewall settings
  3. Ensure the server is currently running
  4. Review authentication credentials

Authentication Errors

Symptoms: 401 Unauthorized or invalid token errors

Solutions:

  1. Verify API keys or tokens are current
  2. Check token permissions and scopes
  3. Ensure OAuth flow completed successfully
  4. Regenerate credentials if needed

Tool Execution Failures

Symptoms: Tools fail or return unexpected errors

Solutions:

  1. Check server logs for detailed error messages
  2. Verify required parameters are provided
  3. Ensure proper authentication scope
  4. Test tools independently

Building a Remote Server

To host your own remote MCP server:

Basic Server Structure

import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
import express from "express";

const app = express();
const server = new Server({
  name: "my-remote-server",
  version: "1.0.0"
});

// Register tools
server.registerTool(
  "my_tool",
  {
    description: "Description of my tool",
    inputSchema: {
      type: "object",
      properties: {
        param: { type: "string" }
      }
    }
  },
  async ({ param }) => {
    // Tool implementation
    return { content: [{ type: "text", text: "Result" }] };
  }
);

// SSE endpoint
app.get("/sse", async (req, res) => {
  const transport = new SSEServerTransport("/message", res);
  await server.connect(transport);
});

app.listen(3000, () => {
  console.log("Remote MCP server running on port 3000");
});

Deployment Considerations

AspectRecommendation
HostingUse reliable cloud provider (AWS, GCP, Azure)
ScalingImplement horizontal scaling with load balancer
MonitoringTrack metrics: latency, error rates, usage
SecurityImplement rate limiting and authentication
LoggingCentralized logging for debugging

Best Practices

  1. Start Local, Go Remote: Develop and test locally before deploying remotely
  2. Graceful Degradation: Handle network failures gracefully
  3. Caching: Implement caching to reduce API calls
  4. Rate Limiting: Respect API quotas and implement client-side limits
  5. Documentation: Clearly document available tools and parameters
  6. Version Management: Use semantic versioning for server updates

Next Steps