> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloudthinker.io/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP

> Connect custom tools and APIs to CloudThinker via Model Context Protocol (MCP) for extensible agent capabilities

Model Context Protocol (MCP) enables CloudThinker to connect to custom tools and services. Use MCP to extend agent capabilities with your own [connections](/guide/connections/overview).

***

## What is MCP?

MCP (Model Context Protocol) is an open protocol for connecting AI agents to external tools and data sources. It provides a standardized way to:

* Expose tools that agents can call
* Provide context and data to agents
* Enable custom integrations with any service

***

## Setup

<Steps>
  <Step title="Prepare MCP Server">
    Ensure your MCP server is running and accessible:

    * Supports Server-Sent Events (SSE) transport
    * Has a publicly accessible endpoint (or VPN access)
    * Returns proper MCP protocol responses
  </Step>

  <Step title="Create Connection">
    Navigate to **Connections → MCP** and click **Add MCP Connection**
  </Step>

  <Step title="Configure Basic Info">
    Enter connection details:

    * **Name**: Descriptive name for the connection
    * **Prefix**: Tool prefix (e.g., `mytools` → `mytools_function_name`)
  </Step>

  <Step title="Configure Transport">
    Set up the connection transport:

    * **Transport Type**: Server-Sent Events
    * **URL**: Your MCP server endpoint
    * **Timeout**: Connection timeout (default: 5 seconds)
    * **SSE Read Timeout**: Event stream timeout (default: 30 seconds)
  </Step>

  <Step title="Add Environment Variables">
    Configure any required environment variables:

    * API keys
    * Authentication tokens
    * Custom configuration
  </Step>

  <Step title="Test & Create">
    Test the connection and save
  </Step>
</Steps>

***

## Configuration Options

| Field                     | Description                       | Required         |
| ------------------------- | --------------------------------- | ---------------- |
| **Name**                  | Connection display name           | Yes              |
| **Prefix**                | Tool name prefix                  | Yes              |
| **URL**                   | MCP server endpoint               | Yes              |
| **Timeout**               | Connection timeout (seconds)      | No (default: 5)  |
| **SSE Read Timeout**      | Event stream timeout (seconds)    | No (default: 30) |
| **Environment Variables** | Key-value pairs for configuration | No               |

***

## Example MCP Server

A simple MCP server that provides a weather lookup tool:

```python theme={null}
from mcp import Server, Tool

server = Server("weather-tools")

@server.tool()
async def get_weather(location: str) -> str:
    """Get current weather for a location."""
    # Your implementation here
    return f"Weather for {location}: Sunny, 72°F"

if __name__ == "__main__":
    server.run()
```

Once connected with prefix `weather`, agents can call:

```
weather_get_weather(location="San Francisco")
```

***

## Use Cases

### Custom Data Sources

Connect proprietary databases or APIs:

* Internal metrics systems
* Custom monitoring tools
* Business intelligence platforms

### Specialized Tools

Add domain-specific capabilities:

* Custom compliance checks
* Internal automation scripts
* Legacy system integrations

### External Services

Integrate third-party services:

* Communication platforms
* Ticketing systems
* Cloud services not built-in

***

## Best Practices

<CardGroup cols={2}>
  <Card title="Security" icon="shield-check">
    * Use HTTPS endpoints
    * Rotate API keys regularly
    * Implement proper authentication
    * Limit tool permissions
  </Card>

  <Card title="Reliability" icon="server">
    * Set appropriate timeouts
    * Implement retry logic
    * Monitor server health
    * Handle errors gracefully
  </Card>
</CardGroup>

***

## Troubleshooting

<Accordion title="Connection timeout">
  * Verify MCP server is running
  * Check network connectivity
  * Increase timeout values
  * Confirm firewall allows traffic
</Accordion>

<Accordion title="Tool not appearing">
  * Verify prefix is set correctly
  * Check MCP server returns tool definitions
  * Ensure protocol version is compatible
  * Review server logs for errors
</Accordion>

<Accordion title="Authentication errors">
  * Verify environment variables are set
  * Check API keys are valid
  * Ensure server validates credentials correctly
</Accordion>

<Accordion title="SSE connection drops">
  * Increase SSE read timeout
  * Check for proxy interference
  * Verify server sends keepalive events
  * Review network stability
</Accordion>

***

## Related

<CardGroup cols={2}>
  <Card title="Overview" icon="plug" href="/guide/connections/overview">
    All connection types
  </Card>

  <Card title="Agents" icon="robot" href="/guide/agents">
    How agents use connections
  </Card>
</CardGroup>
