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

# Overview

> Introduction to secure MCP functions

Soma ships with a high-performance, secure MCP server called Bridge.

Bridge can be used in 2 ways:

* As an MCP server you can give to your agent
* As a standard REST API endpoint that you can invoke directly from your workflow

For example, you can configure your agent, via your SDK of choice, to use Bridge as an MCP server:

<Tabs>
  <Tab title="Typescript / Vercel AI SDK">
    ```typescript theme={null}
        import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse';

        const mcpClient = await createMCPClient({ 
            transport: {
                type: 'http',
                // this is automatically injected by the Soma API server
                url: process.env.SOMA_BRIDGE_MCP_URL,
                headers: {
                    // this is automatically injected by the Soma API server
                    'X-Api-Key': process.env.SOMA_AGENT_API_KEY,
                    // this is automatically injected by the Soma API server
                    'Authorization': `Bearer ${process.env.SOMA_USER_ACCESS_TOKEN}`,
                },
            }
        })
        const tools = await mcpClient.tools();

        const response = await generateText({
            model: 'openai/gpt-4o',
            tools,
            stopWhen: stepCountIs(5),
            messages: [
            {
                role: 'user',
                content: [{ type: 'text', text: 'Find products under $100' }],
            },
            ],
        });
    ```

    Read the [Vercel AI SDK documentation](https://ai-sdk.dev/cookbook/node/mcp-tools) for more details.
  </Tab>

  <Tab title="Python / Langchain">
    ```python theme={null}
    from langchain_mcp_adapters.client import MultiServerMCPClient  
    from langchain.agents import create_openai_tools_agent

    import os

    client = MultiServerMCPClient(
        {
            "soma": {
                "transport": "http",
                # this is automatically injected by the Soma API server
                "url": os.getenv("SOMA_BRIDGE_MCP_URL"),
                "headers": {
                    # this is automatically injected by the Soma API server
                    "X-Api-Key": os.getenv("SOMA_AGENT_API_KEY"),
                    # this is automatically injected by the Soma API server
                    "Authorization": `Bearer ${os.getenv("SOMA_USER_ACCESS_TOKEN")}`,
                },
            }
        }
    )
    tools = await client.get_tools()  
    agent = create_agent(
        "claude-sonnet-4-5-20250929",
        tools  
    )


    ```

    Read the [Langchain documentation](https://docs.langchain.com/oss/python/langchain/mcp) for more details.
  </Tab>
</Tabs>

Alternatively, you can invoke Bridge directly from your code, as if it were a standard REST API client.

<Tabs>
  <Tab title="Typescript / Vercel AI SDK">
    ```typescript theme={null}
    import { type BridgeDefinition, getBridge } from "../soma/bridge";

    // No need to pass in any credentials, they are automatically injected by the Soma API server
    const bridge = getBridge(ctx);
    const res = await bridge.gmailUser.sendEmail({
        to: "test@example.com",
        subject: "Test email",
        body: "This is a test email",
    });
    ```
  </Tab>

  <Tab title="Python / Langchain">
    ```python theme={null}
    from soma.bridge import Bridge, get_bridge

    # Get bridge instance
    # No need to pass in any credentials, they are automatically injected by the Soma API server
    bridge = get_bridge(params.ctx)
    await bridge.gmail_user.send_email(
        to="test@example.com",
        subject="Test email",
        body="This is a test email",
    )
    ```
  </Tab>
</Tabs>

To understand more about about MCP functions, please read:

* [Using built-in SaaS MCP functions](./available-saas-mcp-functions.mdx)
* [Adding custom MCP functions](./adding-custom-functions.mdx)
* [Managing MCP function credentials](./managing-mcp-function-credentials.mdx)
* [Understanding MCP server authentication](./understanding-mcp-server-authentication.mdx)
