Skip to main content
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:
    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 for more details.
Alternatively, you can invoke Bridge directly from your code, as if it were a standard REST API client.
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: "[email protected]",
    subject: "Test email",
    body: "This is a test email",
});
To understand more about about MCP functions, please read: