MCP Usage Examples
Below are common patterns for interacting with the MCP server from external clients. Send each body as an HTTP POST with your Authorization header.
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "list_projects",
"arguments": { "limit": 10 }
}
}{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "create_file",
"arguments": {
"project_id": "your-project-uuid",
"path": "src/components/NewWidget.tsx",
"content": "export default function NewWidget() { return <div>Hello</div>; }"
}
}
}{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "search_replace_file",
"arguments": {
"project_id": "your-project-uuid",
"path": "src/components/NewWidget.tsx",
"search": "<div>Hello</div>",
"replace": "<div>Hello, world</div>"
}
}
}{
"jsonrpc": "2.0",
"id": 5,
"method": "tools/call",
"params": {
"name": "search_files",
"arguments": {
"project_id": "your-project-uuid",
"query": "useState"
}
}
}{
"jsonrpc": "2.0",
"id": 6,
"method": "resources/read",
"params": { "uri": "cloudcode://project/your-project-uuid/file-tree" }
}Call stream_start to get a message_id, send stream_chunk with the full text so far as often as you like, then finish with stream_end:
{
"jsonrpc": "2.0",
"id": 7,
"method": "tools/call",
"params": {
"name": "stream_start",
"arguments": { "project_id": "your-project-uuid", "source": "claude-code" }
}
}{
"jsonrpc": "2.0",
"id": 8,
"method": "tools/call",
"params": {
"name": "stream_end",
"arguments": { "message_id": "<message_id from stream_start>", "content": "Done." }
}
}tools/list to dynamically discover all available tools and their input schemas. This ensures your integration stays compatible even as new tools are added.Add the server with the CLI:
claude mcp add --transport http cloudcode https://tytvylihloorkrcgkzok.supabase.co/functions/v1/mcp-server \ --header "Authorization: Bearer <access_token>"
Or commit a project-scoped .mcp.json (keep the token in an environment variable):
{
"mcpServers": {
"cloudcode": {
"type": "http",
"url": "https://tytvylihloorkrcgkzok.supabase.co/functions/v1/mcp-server",
"headers": {
"Authorization": "Bearer ${CLOUDCODE_ACCESS_TOKEN}"
}
}
}
}Add to ~/.cursor/mcp.json (or .cursor/mcp.json in a project):
{
"mcpServers": {
"cloudcode": {
"url": "https://tytvylihloorkrcgkzok.supabase.co/functions/v1/mcp-server",
"headers": {
"Authorization": "Bearer <access_token>"
}
}
}
}Claude Desktop's claude_desktop_config.json launches local (stdio) servers, so connect through the mcp-remote bridge, which forwards requests to the HTTP endpoint with your header:
{
"mcpServers": {
"cloudcode": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://tytvylihloorkrcgkzok.supabase.co/functions/v1/mcp-server",
"--header",
"Authorization:${CLOUDCODE_AUTH}"
],
"env": {
"CLOUDCODE_AUTH": "Bearer <access_token>"
}
}
}
}