Semaphor
MCPClient Setup

Programmatic Access

Connect your own AI agents and scripts to Semaphor MCP.

Build custom AI integrations, scripts, or automation that query Semaphor data through the MCP protocol.

MCP Endpoint

https://semaphor.cloud/api/mcp

Authentication

Use a project token passed as a Bearer token in the Authorization header.

Using the MCP SDK (TypeScript)

The @modelcontextprotocol/sdk package provides a typed client for MCP servers:

mcp-client.ts
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';

const transport = new StreamableHTTPClientTransport(
  new URL('https://semaphor.cloud/api/mcp'),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${process.env.SEMAPHOR_TOKEN}`,
      },
    },
  }
);

const client = new Client({ name: 'my-agent', version: '1.0.0' });
await client.connect(transport);

// List available tools
const { tools } = await client.listTools();
console.log('Available tools:', tools.map(t => t.name));

// Call a tool
const result = await client.callTool({
  name: 'semaphor_get_analysis_context',
  arguments: {},
});
console.log(result);

Using HTTP Directly

For non-MCP clients, use JSON-RPC over HTTP.

List Available Tools

List tools
curl -X POST https://semaphor.cloud/api/mcp \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'

Call a Tool

Call a discovery tool
curl -X POST https://semaphor.cloud/api/mcp \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "semaphor_get_analysis_context",
      "arguments": {}
    },
    "id": 2
  }'

Execute a Query

Run a SQL query
curl -X POST https://semaphor.cloud/api/mcp \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "semaphor_query_sql",
      "arguments": {
        "connectionId": "conn_abc123",
        "sql": "SELECT region, COUNT(*) as orders FROM orders GROUP BY region"
      }
    },
    "id": 3
  }'

Python Example

mcp_query.py
import requests

TOKEN = "your_project_token"
ENDPOINT = "https://semaphor.cloud/api/mcp"

headers = {
    "Authorization": f"Bearer {TOKEN}",
    "Content-Type": "application/json",
}

# Get analysis context
response = requests.post(
    ENDPOINT,
    headers=headers,
    json={
        "jsonrpc": "2.0",
        "method": "tools/call",
        "params": {
            "name": "semaphor_get_analysis_context",
            "arguments": {},
        },
        "id": 1,
    },
)

print(response.json())

TypeScript / JavaScript Example

mcp-fetch.ts
const TOKEN = process.env.SEMAPHOR_TOKEN;
const ENDPOINT = 'https://semaphor.cloud/api/mcp';

// List dashboards
const response = await fetch(ENDPOINT, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    jsonrpc: '2.0',
    method: 'tools/call',
    params: {
      name: 'semaphor_list_dashboards',
      arguments: { projectId: 'p_abc123' },
    },
    id: 1,
  }),
});

const result = await response.json();
console.log(result);

Connection Parameters for Other MCP Clients

ParameterValue
MCP Endpointhttps://semaphor.cloud/api/mcp
TransportHTTP (Streamable HTTP)
Auth TypeBearer token
Auth HeaderAuthorization: Bearer <project_token>

For clients that support OAuth, use Client ID 6e255134da304553998418c53bd59d85. See the Authentication page for all OAuth configuration parameters.

On this page