> ## 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. CloudThinker shows a **Connected** status when the server responds correctly.
  </Step>
</Steps>

***

## Connection details

| 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

* **HTTPS endpoints** — expose your MCP server only over HTTPS.
* **Rotate API keys** — rotate credentials stored in environment variables on your normal schedule.
* **Implement authentication** — validate incoming requests from CloudThinker before processing.
* **Set appropriate timeouts** — tune Timeout and SSE Read Timeout to match your server's response characteristics.
* **Monitor server health** — track error rates and latency so connection drops are caught early.
* **Handle errors gracefully** — return structured MCP error responses rather than crashing the server.

***

## Troubleshooting

<Accordion title="Connection timeout">
  Verify the MCP server is running, check network connectivity, increase timeout values, and confirm the firewall allows traffic.
</Accordion>

<Accordion title="Tool not appearing">
  Verify the prefix is set correctly, check that the MCP server returns tool definitions, ensure the protocol version is compatible, and review server logs for errors.
</Accordion>

<Accordion title="Authentication errors">
  Verify environment variables are set correctly, check that API keys are valid, and ensure the server validates credentials correctly.
</Accordion>

<Accordion title="SSE connection drops">
  Increase the SSE read timeout, check for proxy interference, verify the server sends keepalive events, and review network stability.
</Accordion>

***

## Security

* **Least privilege** — grant only the permissions the agents need for your use case; start read-only and widen later.
* **Read-only by default** — use read-only credentials unless you want agents to make changes through this connection.
* **Rotate credentials** — rotate keys and tokens on your normal schedule; CloudThinker picks up the new value when you update the connection.
* **Revoke on offboarding** — remove the credential at the provider when you delete a connection or a teammate leaves.

- **HTTPS endpoints** — expose your MCP server only over HTTPS and validate the CloudThinker request origin.
- **Scoped credentials** — store API keys and tokens in environment variables rather than hardcoding them in server code.

***

## 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>
