### Node.js Setup and Run Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/configuration.md Install dependencies, build the project, and run the server using Node.js. Set the API_KEY environment variable before running. ```bash pnpm install pnpm build API_KEY=your-key node dist/index.js ``` -------------------------------- ### Get Document Example Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Example of how to fetch a document using the SDK, demonstrating both default error handling and throwing errors. ```APIDOC ## Use SDK functions ```typescript import { getDoc } from "./client/sdk.gen"; // Example with default error handling const result = await getDoc({ path: { docId: "invalid" } }); if (!result.error) { console.log(result.data); } else { console.log(result.error.message); } // Example with error throwing enabled try { const docResult = await getDoc({ path: { docId: "doc-123" }, throwOnError: true, }); console.log(docResult.data.name); } catch (error) { console.error(error.message); } ``` ``` -------------------------------- ### Client SDK Configuration Example Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/MANIFEST.md Shows how to configure the HTTP client SDK, typically using Axios. This setup is necessary before making requests to the Coda API. ```typescript import { CodaClient } from "@coda/client-sdk"; const client = new CodaClient({ // Axios configuration options baseURL: "https://api.coda.io/v1", headers: { Authorization: "Bearer YOUR_API_KEY", }, }); ``` -------------------------------- ### Install and Build Coda MCP Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Install dependencies and build the project using pnpm. ```bash cd coda-mcp pnpm install pnpm build ``` -------------------------------- ### Install and Run Coda MCP Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/README.md Install dependencies, build the TypeScript project, and run the Coda MCP server with an API key. ```bash # Install dependencies pnpm install # Build TypeScript pnpm build # Run with API key API_KEY=your-coda-api-key node dist/index.js ``` -------------------------------- ### Initialize and Connect Coda MCP Server Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Example of initializing the MCP server with Axios client configuration and connecting via stdio. This setup allows the server to receive tool calls from MCP clients. ```typescript import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { client } from "./client/client.gen"; import { config } from "./config"; import { server } from "./server"; async function main() { client.setConfig({ baseURL: "https://coda.io/apis/v1", headers: { Authorization: `Bearer ${config.apiKey}`, }, }); const transport = new StdioServerTransport(); await server.connect(transport); console.error("Coda MCP server running on stdio"); } main().catch((error) => { console.error("Fatal error in main():", error); process.exit(1); }); ``` -------------------------------- ### Install and Run Coda MCP Server Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/00-START-HERE.md Use this command to install and run the Coda MCP Server locally. Ensure your API key is set as an environment variable. ```bash API_KEY=your-coda-api-key npx coda-mcp@latest ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/dustinrgood/coda-mcp/blob/main/README.md Clone the Coda MCP repository and install project dependencies using pnpm. ```bash git clone cd coda-mcp pnpm install ``` -------------------------------- ### Client Configuration Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md The client is configured once during server initialization. This example shows how to set the baseURL and Authorization header. ```APIDOC ## Client Configuration The client is configured once during server initialization in `src/index.ts`: ```typescript import { client } from "./client/client.gen"; import { config } from "./config"; client.setConfig({ baseURL: "https://coda.io/apis/v1", headers: { Authorization: `Bearer ${config.apiKey}`, }, }); ``` **Configuration Applied**: - **baseURL**: All requests are made to `https://coda.io/apis/v1` - **Authorization Header**: Every request includes `Bearer {API_KEY}` ``` -------------------------------- ### MCP Server Initialization Example Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/MANIFEST.md Demonstrates how to initialize the McpServer with a given configuration. This is a foundational step for using the MCP server tools. ```typescript import { McpServer } from "@coda/mcp-server"; const server = new McpServer({ // Configuration options }); server.start(); ``` -------------------------------- ### Coda API Pagination Example Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Demonstrates how to use the nextPageToken to retrieve subsequent pages of results from collection endpoints. ```python First call: coda_list_pages(docId, limit=10) → Returns 10 items + nextPageToken="xyz" Next call: coda_list_pages(docId, nextPageToken="xyz") → Returns next 10 items ``` -------------------------------- ### Configure Coda MCP with npx/npm Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/configuration.md Example JSON configuration for running Coda MCP using npx or npm. Ensure the API_KEY is correctly set in the environment. ```json { "mcpServers": { "coda": { "command": "npx", "args": ["-y", "coda-mcp@latest"], "env": { "API_KEY": "your-api-key-here" } } } } ``` -------------------------------- ### Configure Coda MCP with Docker Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/configuration.md Example JSON configuration for running Coda MCP using Docker. The API_KEY is passed as an environment variable to the container. ```json { "mcpServers": { "coda": { "command": "docker", "args": ["run", "-i", "--rm", "-e", "API_KEY", "dustingood/coda-mcp:latest"], "env": { "API_KEY": "your-api-key-here" } } } } ``` -------------------------------- ### Usage Example for getPageContent Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/helpers.md Demonstrates how to use the `getPageContent` function to export a page's markdown content and handle potential errors. ```typescript import { getPageContent } from "./client/helpers"; async function exportPageMarkdown() { try { const content = await getPageContent("doc-123", "my-page"); console.log("Page markdown:\n", content); } catch (error) { console.error("Export failed:", error.message); } } ``` -------------------------------- ### beginPageContentExport Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Starts an asynchronous export of page content. Requires document ID, page ID or name, and output format (markdown). ```APIDOC ## beginPageContentExport ### Description Start an async page content export. Requires document ID, page ID or name, and output format (markdown). ### Method Not applicable (SDK function) ### Parameters #### Options - `path.docId` (string) - Document ID (required) - `path.pageIdOrName` (string) - Page ID or name (required) - `body.outputFormat` (string) - "markdown" (required) ### Returns Export request with `id` field ``` -------------------------------- ### Dockerfile Configuration Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/configuration.md Configure the Dockerfile for building the Coda MCP image. This includes setting the working directory, copying files, installing dependencies, building the project, and setting the entrypoint. ```dockerfile FROM node:22-alpine WORKDIR /app COPY . . RUN pnpm install --frozen-lockfile RUN pnpm build ENV API_KEY="" ENTRYPOINT ["node", "dist/index.js"] ``` -------------------------------- ### Request Path Transformation Example Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/ARCHITECTURE.md Shows the transformation of a tool input into an HTTP request for fetching Coda page content, including validation and API call details. ```typescript // Tool input { docId: "doc-123", pageIdOrName: "my-page" } // After validation type GetPageContentParams = { docId: string; pageIdOrName: string; } // HTTP request GET /docs/doc-123/pages/my-page?... Authorization: Bearer {key} // Response { id: "page-123", name: "my-page", ... } ``` -------------------------------- ### Coda Tool: Get Document Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Retrieves a document's metadata. Requires a valid `docId`. ```text Tool: coda_get_document Parameters: docId: "doc-abc123" Returns: Doc object with metadata ``` -------------------------------- ### HTTP Client SDK Function Pattern Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/ARCHITECTURE.md Example of a function pattern within the auto-generated HTTP client SDK, demonstrating how to make requests with options for error handling. ```typescript export const getDoc = ( options: Options ) => { return client.post({ path: "/docs/{docId}", pathParams: { docId: options.path.docId }, throwOnError: options?.throwOnError ?? false, }); } ``` -------------------------------- ### Coda Tool: Get Page Content as Markdown Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Fetches the content of a specific page as raw markdown text. Requires `docId` and `pageIdOrName`. ```text Tool: coda_get_page_content Parameters: docId: "doc-abc123" pageIdOrName: "my-page" Returns: Raw markdown text ``` -------------------------------- ### Get Page Content as Markdown Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Fetches the content of a specific page within a document in raw markdown format. ```APIDOC ## coda_get_page_content ### Description Fetches the content of a specific page within a document in raw markdown format. ### Parameters #### Path Parameters - **docId** (string) - Required - The ID of the document. - **pageIdOrName** (string) - Required - The ID or name of the page. ### Returns Raw markdown text ``` -------------------------------- ### Helper Function getPageContent Example Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/MANIFEST.md Illustrates the usage of the getPageContent helper function to retrieve the content of a page. It includes constants for retry logic. ```typescript import { getPageContent } from "@coda/helpers"; const MAX_RETRIES = 3; const RETRY_DELAY = 1000; async function fetchPage(pageId: string): Promise { return getPageContent(pageId, MAX_RETRIES, RETRY_DELAY); } ``` -------------------------------- ### Example JSON Error Response Structure Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/errors.md Illustrates the expected JSON structure for an error response from the Coda MCP Server, including the content and isError fields. ```json { "content": [{ "type": "text", "text": "Failed to get document : Document not found" }], "isError": true } ``` -------------------------------- ### Client SDK Functions Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/MANIFEST.md Reference for the HTTP client SDK functions, organized by endpoint type. Each function includes its signature, options parameters, return type, and usage examples. ```APIDOC ## Client SDK Functions Reference This section details the functions available in the HTTP client SDK for interacting with the Coda MCP. ### Function Categories: - Document functions: 5 functions - Page functions: 8 functions - Table functions: 2 functions - Column functions: 2 functions - Row functions: 6 functions - Formula functions: 2 functions - Control functions: 4 functions - User function: 1 function ### Function Documentation: Each function is documented with: - Full signature - Options parameters - Return type - Which server tools it is used by ### Options Type Explanation: Details on the structure and usage of options parameters. ### Error Handling: Explanation of the three error handling patterns used by the SDK. ### Response Format: Description of both success and error response formats. ### Usage Example: A direct SDK usage example. ``` -------------------------------- ### MCP Server Tools Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/MANIFEST.md Reference for the 37 tools available on the MCP server, organized by category. Each tool includes its Zod schema, parameters, return type, error conditions, and usage examples. ```APIDOC ## MCP Server Tools Reference This section details the available tools on the MCP server, categorized for ease of use. ### Categories and Tool Counts: - Document Operations: 5 tools - Page Operations: 8 tools - Table Operations: 3 tools - Column Operations: 2 tools - Row Operations: 6 tools - Formula Operations: 2 tools - Control Operations: 3 tools - User Operations: 1 tool - Search Operations: 2 tools - Batch Operations: 1 tool - Analytics: 1 tool ### Tool Documentation: Each tool is documented with: - Full Zod schema - Parameter table - Return type - Error conditions - Usage example - Source location ### Error Handling: Details on the error handling pattern used by the server. ### Usage Example: A complete setup example demonstrating how to use the MCP server tools. ``` -------------------------------- ### coda_peek_page Tool Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Use this tool to get a limited preview of a page's content. Specify the document ID, page ID or name, and the number of lines to retrieve from the beginning of the page. ```typescript server.tool( "coda_peek_page", "Peek into the beginning of a page and return a limited number of lines", { docId: z.string().describe("The ID of the document that contains the page to peek into"), pageIdOrName: z.string().describe("The ID or name of the page to peek into"), numLines: z.number().int().positive().describe("The number of lines to return from the start of the page - usually 30 lines is enough"), }, async ({ docId, pageIdOrName, numLines }): Promise ) ``` -------------------------------- ### coda_get_formula Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Get detailed information about a specific formula. ```APIDOC ## coda_get_formula ### Description Get detailed information about a specific formula. ### Method server.tool ### Parameters #### Path Parameters - **docId** (string) - Required - The ID of the document containing the formula - **formulaIdOrName** (string) - Required - The ID or name of the formula to get information about ### Response #### Success Response (200) - **formulaDetails** (object) - JSON-serialized formula details ``` -------------------------------- ### Get a Document Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Retrieves a document by its ID, returning metadata about the document. ```APIDOC ## coda_get_document ### Description Retrieves a document by its ID, returning metadata about the document. ### Parameters #### Path Parameters - **docId** (string) - Required - The ID of the document to retrieve. ### Returns Doc object with metadata ``` -------------------------------- ### Document Operations Source: https://github.com/dustinrgood/coda-mcp/blob/main/README.md Operations for listing, retrieving, creating, updating, and getting statistics for Coda documents. ```APIDOC ## coda_list_documents ### Description List or search available documents with optional filtering. ### Method APICALL ### Endpoint /coda/documents/list ## coda_get_document ### Description Get detailed information about a specific document. ### Method APICALL ### Endpoint /coda/documents/get ## coda_create_document ### Description Create a new document, optionally from a template. ### Method APICALL ### Endpoint /coda/documents/create ## coda_update_document ### Description Update document properties like title and icon. ### Method APICALL ### Endpoint /coda/documents/update ## coda_get_document_stats ### Description Get comprehensive statistics and insights about a document. ### Method APICALL ### Endpoint /coda/documents/stats ``` -------------------------------- ### Build Docker Image Source: https://github.com/dustinrgood/coda-mcp/blob/main/README.md Create a Docker image for the Coda MCP server. This command should be run from the root of the repository. ```bash docker build -t dustingood/coda-mcp:latest . ``` -------------------------------- ### coda_get_document_stats Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Get statistics and insights about a document. This tool provides aggregated counts and breakdowns of document elements. ```APIDOC ## coda_get_document_stats ### Description Get statistics and insights about a document. ### Method POST ### Endpoint /tools/coda_get_document_stats ### Parameters #### Path Parameters - **docId** (string) - Required - The ID of the document to analyze ### Request Example { "docId": "doc123" } ### Response #### Success Response (200) - **CallToolResult** - Contains a JSON object with document statistics. - **document** (object) - Basic document metadata (id, name, owner, dates, size) - **counts** (object) - Aggregated counts (pages, tables, views, formulas, controls) - **breakdown** (object) - Sample names of tables, pages (first 10), and formulas (first 10) #### Response Example { "tool_code": "coda_get_document_stats", "tool_input": { "docId": "doc123" }, "output": "{\"document\": {\"id\": \"doc123\", \"name\": \"Example Document\", \"owner\": \"user1\", \"createdAt\": \"2023-01-01T10:00:00Z\", \"updatedAt\": \"2023-01-01T10:00:00Z\", \"size\": 1024},\"counts\": {\"pages\": 5, \"tables\": 3, \"views\": 2, \"formulas\": 10, \"controls\": 1},\"breakdown\": {\"tables\": [\"Table1\", \"Table2\"], \"pages\": [\"Page1\", \"Page2\"], \"formulas\": [\"Formula1\", \"Formula2\"]}}" } ``` -------------------------------- ### Configure Coda MCP Server with npx Source: https://github.com/dustinrgood/coda-mcp/blob/main/README.md Add the MCP server to Cursor/Claude Desktop/etc. using npx. Ensure your API_KEY environment variable is set. ```json { "mcpServers": { "coda": { "command": "npx", "args": ["-y", "coda-mcp@latest"], "env": { "API_KEY": "..." } } } } ``` -------------------------------- ### Get Document Statistics Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Retrieves statistics and metadata about a document, including counts of pages, tables, and other elements. ```APIDOC ## coda_get_document_stats ### Description Retrieves statistics and metadata about a document, including counts of pages, tables, and other elements. ### Parameters #### Path Parameters - **docId** (string) - Required - The ID of the document. ### Returns { document: { id, name, owner, dates, size }, counts: { pages, tables, views, formulas, controls }, breakdown: { tableNames, pageNames, formulaNames } } ``` -------------------------------- ### Configure and Use Coda SDK Directly Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Configure the SDK client with your API key and base URL, then use SDK functions for direct API interactions. ```typescript import { client } from "./client/client.gen"; import { getDoc, createPage } from "./client/sdk.gen"; // Configure client client.setConfig({ baseURL: "https://coda.io/apis/v1", headers: { Authorization: `Bearer YOUR_API_KEY`, }, }); // Use SDK functions const docResult = await getDoc({ path: { docId: "doc-123" }, throwOnError: true, }); console.log(docResult.data.name); ``` -------------------------------- ### Initialize MCP Server Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/configuration.md Initialize the MCP server with static metadata. The version is automatically read from package.json. ```typescript const server = new McpServer({ name: "coda-enhanced", version: packageJson.version, capabilities: { resources: {}, tools: {}, }, }); ``` -------------------------------- ### Get Current User Information Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Retrieves information about the currently authenticated user. This function does not require any specific options. ```typescript export const whoami = ( options?: Options ) => { ... } ``` -------------------------------- ### Test Server Locally Source: https://github.com/dustinrgood/coda-mcp/blob/main/README.md Run the compiled JavaScript server locally. Set the API_KEY environment variable before execution. ```bash API_KEY=your-api-key node dist/index.js ``` -------------------------------- ### coda_get_document Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Get detailed information about a specific document using its ID. This tool retrieves comprehensive details for a given document. ```APIDOC ## coda_get_document ### Description Get detailed information about a specific document. ### Method POST ### Endpoint /tools/coda_get_document ### Parameters #### Path Parameters - **docId** (string) - Required - The ID of the document to get information about ### Request Example { "docId": "doc123" } ### Response #### Success Response (200) - **CallToolResult** - Contains a JSON-serialized document details. #### Response Example { "tool_code": "coda_get_document", "tool_input": { "docId": "doc123" }, "output": "{\"id\": \"doc123\", \"name\": \"Example Document\", \"owner\": \"user1\", \"createdAt\": \"2023-01-01T10:00:00Z\", \"updatedAt\": \"2023-01-01T10:00:00Z\"}" } ``` -------------------------------- ### Add New Tool to Server Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/ARCHITECTURE.md Register a new tool with its name, description, parameters, and an asynchronous implementation function. Ensure to follow the error pattern with try/catch. ```typescript server.tool("tool_name", "description", { param: z.string(), }, async ({ param }): Promise => { // implementation }); ``` -------------------------------- ### Docker Run Command Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/configuration.md Run the Coda MCP Docker container. Ensure the API_KEY environment variable is set. ```bash docker run -i --rm -e API_KEY=your-key dustingood/coda-mcp:latest ``` -------------------------------- ### Test Docker Image Source: https://github.com/dustinrgood/coda-mcp/blob/main/README.md Run the Coda MCP server within a Docker container. Ensure the API_KEY is passed as an environment variable. ```bash docker run -i --rm -e API_KEY=your-api-key dustingood/coda-mcp:latest ``` -------------------------------- ### Get Coda Control Details Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Retrieve detailed information about a specific control within a Coda document using its ID or name. ```typescript server.tool( "coda_get_control", "Get detailed information about a specific control", { docId: z.string().describe("The ID of the document containing the control"), controlIdOrName: z.string().describe("The ID or name of the control to get information about"), }, async ({ docId, controlIdOrName }): Promise ) ``` -------------------------------- ### Build the Project Source: https://github.com/dustinrgood/coda-mcp/blob/main/README.md Compile the TypeScript code to JavaScript for local execution or Docker image creation. ```bash pnpm build ``` -------------------------------- ### Run Development Build Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/ARCHITECTURE.md Compiles TypeScript to ES2020 JavaScript with declaration files. Outputs to the dist directory. ```bash pnpm build # Outputs: dist/index.js + dist/**.d.ts ``` -------------------------------- ### Get Coda Column Details Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Retrieves detailed information about a specific column in a Coda table. Requires document, table, and column identifiers. ```typescript server.tool( "coda_get_column", "Get detailed information about a specific column", { docId: z.string().describe("The ID of the document containing the table"), tableIdOrName: z.string().describe("The ID or name of the table containing the column"), columnIdOrName: z.string().describe("The ID or name of the column to get information about"), }, async ({ docId, tableIdOrName, columnIdOrName }): Promise ) ``` -------------------------------- ### Create a New Coda Document Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Create a new document from scratch or by using a template. You can specify the title, source document, folder, and timezone. ```typescript export const createDoc = ( options: Options ) => { ... } ``` -------------------------------- ### Client Configuration Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Configure the Coda client with your API base URL and authentication headers. ```APIDOC ## Configure client ```typescript import { client } from "./client/client.gen"; client.setConfig({ baseURL: "https://coda.io/apis/v1", headers: { Authorization: `Bearer YOUR_API_KEY`, }, }); ``` ``` -------------------------------- ### Get Specific Coda Table Information Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Fetch detailed information about a particular table or view in a Coda document using its ID or name. ```typescript server.tool( "coda_get_table", "Get detailed information about a specific table or view", { docId: z.string().describe("The ID of the document containing the table"), tableIdOrName: z.string().describe("The ID or name of the table to get information about"), }, async ({ docId, tableIdOrName }): Promise ) ``` -------------------------------- ### Get Coda Row Details Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Retrieves detailed information about a specific row in a Coda table. Supports returning data using column names. ```typescript server.tool( "coda_get_row", "Get detailed information about a specific row", { docId: z.string().describe("The ID of the document containing the table"), tableIdOrName: z.string().describe("The ID or name of the table containing the row"), rowIdOrName: z.string().describe("The ID or name of the row to get information about"), useColumnNames: z.boolean().optional().describe("Use column names instead of IDs in output"), }, async ({ docId, tableIdOrName, rowIdOrName, useColumnNames }): Promise ) ``` -------------------------------- ### Configure Coda MCP Client with Docker Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Configuration for running the Coda MCP client using Docker. The API_KEY is passed as an environment variable to the container. ```json { "mcpServers": { "coda": { "command": "docker", "args": ["run", "-i", "--rm", "-e", "API_KEY", "dustingood/coda-mcp:latest"], "env": { "API_KEY": "your-key" } } } } ``` -------------------------------- ### Run Coda MCP Locally Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Execute the Coda MCP client locally, providing the API key via an environment variable. ```bash API_KEY=your-coda-api-key node dist/index.js ``` -------------------------------- ### Get a Specific Control Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Fetches a specific control from a document using its ID or name. This function requires the document ID and the control's ID or name. ```typescript export const getControl = ( options: Options ) => { ... } ``` -------------------------------- ### Import MCP SDK and Utilities Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Imports necessary components from the MCP SDK, including the server class, result types, Zod for validation, package information, helper functions, and generated SDK methods for interacting with Coda resources. ```typescript import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; import z from "zod"; import packageJson from "../package.json"; import { getPageContent } from "./client/helpers"; import { createPage, listDocs, listPages, updatePage, listTables, getTable, listColumns, listRows, upsertRows, deleteRows, getRow, updateRow, deleteRow, getColumn, listFormulas, getFormula, listControls, getControl, pushButton, whoami, getDoc, updateDoc, createDoc, deletePage } from "./client/sdk.gen"; ``` -------------------------------- ### Get a Specific Formula Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Retrieve details of a particular formula by its ID or name within a document. Requires the document ID and the formula's ID or name. ```typescript export const getFormula = ( options: Options ) => { ... } ``` -------------------------------- ### Cursor/Claude Desktop MCP Configuration Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/configuration.md Add this configuration to your MCP configuration file to integrate Coda MCP with Cursor or Claude Desktop. Replace 'your-api-key' with your actual Coda API key. ```json { "mcpServers": { "coda": { "command": "npx", "args": ["-y", "coda-mcp@latest"], "env": { "API_KEY": "your-api-key" } } } } ``` -------------------------------- ### Get a Specific Row Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Fetch a single row from a table by its ID or name. This function can return row data using column names for easier access. ```typescript export const getRow = ( options: Options ) => { ... } ``` -------------------------------- ### Coda Tool: Create a Page Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Creates a new page within a document. Optionally specify `name`, `content` in markdown, and `parentPageId` for nesting. ```text Tool: coda_create_page Parameters: docId: "doc-abc123" name: "New Page" content: "# Markdown content" (optional) parentPageId: "parent-id" (optional, for nesting) Returns: Created Page ``` -------------------------------- ### Get Coda Page Content Export Status Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Poll for the status of an ongoing page content export. Provides the status and a download link upon completion. ```typescript export const getPageContentExportStatus = ( options: Options ) => { ... } ``` -------------------------------- ### Run Tests with Vitest Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Executes tests using the Vitest framework. Test files are typically located in `src/**/*.test.ts`. Ensure your tests cover critical functionality. ```bash pnpm test ``` -------------------------------- ### Get Coda Document Details Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Retrieve specific details for a given document using its ID. This function is utilized by server tools for fetching document information. ```typescript export const getDoc = ( options: Options ) => { ... } ``` -------------------------------- ### Regenerate SDK from OpenAPI Spec Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/ARCHITECTURE.md Use this command to regenerate the SDK files (`sdk.gen.ts` and `types.gen.ts`) from the Coda API specification. ```bash pnpm openapi-ts ``` -------------------------------- ### Coda Tool: Get Document Statistics Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Retrieves statistics and metadata for a document, including counts of pages, tables, views, and formulas, as well as breakdowns by name. ```text Tool: coda_get_document_stats Parameters: docId: "doc-abc123" Returns: { document: { id, name, owner, dates, size }, counts: { pages, tables, views, formulas, controls }, breakdown: { tableNames, pageNames, formulaNames } } ``` -------------------------------- ### Import Coda MCP Types Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/types.md Import various types from the client module for use in your project. Ensure the client module is correctly referenced. ```typescript import type { Doc, DocList, Page, PageList, Table, TableList, Column, ColumnList, Row, RowList, Formula, FormulaList, Control, ControlList, User, Workspace, Permission, Type, AccessType, } from "./client/types"; ``` -------------------------------- ### Begin Coda Page Content Export Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Initiate an asynchronous export of a page's content in Markdown format. Returns an export request ID. ```typescript export const beginPageContentExport = ( options: Options ) => { ... } ``` -------------------------------- ### Get Table Details Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Retrieve detailed information about a specific table or view using its ID or name within a document. This is useful for understanding the structure and metadata of a table. ```typescript export const getTable = ( options: Options ) => { ... } ``` -------------------------------- ### Push Docker Image to Hub Source: https://github.com/dustinrgood/coda-mcp/blob/main/README.md Upload the built Docker image to Docker Hub for distribution. ```bash docker push dustingood/coda-mcp:latest ``` -------------------------------- ### Create a Page in a Coda Document Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Add a new page to an existing document. You can set the page name, subtitle, icon, parent page, and initial content. ```typescript export const createPage = ( options: Options ) => { ... } ``` -------------------------------- ### Example Validation Error Response Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/errors.md This JSON structure represents a typical validation error returned by the MCP framework. It indicates an invalid request parameter and provides a human-readable message. ```json { "error": { "type": "invalid_request_params", "message": "Invalid parameter: limit must be a positive integer" } } ``` -------------------------------- ### Function Signature Pattern Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md All SDK functions follow a consistent pattern, accepting an optional options object for query, body, and error handling. ```APIDOC ## Function Signature Pattern All SDK functions follow the same pattern: ```typescript export const functionName = ( options?: Options ) => { return client.post({ path: "/endpoint/path", query: options?.query, body: options?.body, throwOnError: options?.throwOnError ?? false, }); } ``` **Generic Parameters**: - `ThrowOnError`: Boolean type parameter (default: false) - When `true`, the function throws on HTTP errors - When `false`, the function returns error responses **Options Parameter**: - `path`: Path parameters (IDs, names) - `query`: Query string parameters - `body`: Request body (for POST/PATCH/PUT) - `throwOnError`: Whether to throw on errors ``` -------------------------------- ### DocCreate Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/types.md Defines the payload structure for creating a new Coda document, including optional fields for title, source document, timezone, and folder. ```APIDOC ## DocCreate ### Description Payload for creating a new document. ### Used By - `coda_create_document` — accepts DocCreate in request body ### Notes - `sourceDoc`: If provided, creates a copy of the source document - `folderId`: If not provided, creates in default "My docs" folder - `timezone`: Affects how date/time functions operate in the doc ### Field Details - `title` (string, optional): Document title (defaults to "Untitled") - `sourceDoc` (string, optional): Doc ID to copy from - `timezone` (string, optional): Timezone for new doc - `folderId` (string, optional): Folder ID (optional) - `initialPage` (PageCreate, optional): Initial page to create ### Type Definition ```typescript export type DocCreate = { title?: string; sourceDoc?: string; timezone?: string; folderId?: string; initialPage?: PageCreate; }; ``` ``` -------------------------------- ### Coda Tool: List Pages in Document Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Lists pages within a document. Supports optional `limit` and `nextPageToken` for pagination. ```text Tool: coda_list_pages Parameters: docId: "doc-abc123" limit: 25 (optional) nextPageToken: (optional, for pagination) Returns: PageList (items + pagination token) ``` -------------------------------- ### Get Specific Formula Details in Coda Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Fetch detailed information about a particular formula in a Coda document. You need to provide the document ID and the formula's ID or name. ```typescript server.tool( "coda_get_formula", "Get detailed information about a specific formula", { docId: z.string().describe("The ID of the document containing the formula"), formulaIdOrName: z.string().describe("The ID or name of the formula to get information about"), }, async ({ docId, formulaIdOrName }): Promise ) ``` -------------------------------- ### Get Column Details Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Obtain detailed information about a specific column within a table. This function requires the document ID, table ID or name, and the column ID or name. ```typescript export const getColumn = ( options: Options ) => { ... } ``` -------------------------------- ### Configure Coda MCP Client Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Configure the Coda MCP client once during server initialization. This sets the base URL for all requests and includes the Authorization header with your API key. ```typescript import { client } from "./client/client.gen"; import { config } from "./config"; client.setConfig({ baseURL: "https://coda.io/apis/v1", headers: { Authorization: `Bearer ${config.apiKey}`, }, }); ``` -------------------------------- ### Get Specific Coda Document Details Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Retrieve detailed information about a specific Coda document using its unique ID. The tool returns a CallToolResult containing the document's details. ```typescript server.tool( "coda_get_document", "Get detailed information about a specific document", { docId: z.string().describe("The ID of the document to get information about"), }, async ({ docId }): Promise ) ``` -------------------------------- ### Get Page Content as Markdown Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/helpers.md Exports a page's content as markdown by initiating an export, polling for completion, and downloading the result. Handles errors during initiation, status checks, and download. ```typescript export async function getPageContent(docId: string, pageIdOrName: string): Promise ``` -------------------------------- ### Coda API Push Button Error Handling Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/errors.md Describes possible errors when using the 'coda_push_button' operation, including button not found, row not found, execution failures, and permission denied. ```text Failed to push button : Column not found or is not a button Failed to push button : Row not found Failed to push button : Forbidden ``` -------------------------------- ### Get Coda Page Content Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Use this tool to retrieve the full markdown content of a specific page within a Coda document. Requires the document ID and the page's ID or name. ```typescript server.tool( "coda_get_page_content", "Get the content of a page as markdown", { docId: z.string().describe("The ID of the document that contains the page to get the content of"), pageIdOrName: z.string().describe("The ID or name of the page to get the content of"), }, async ({ docId, pageIdOrName }): Promise ) ``` -------------------------------- ### listControls Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/client-sdk.md Lists all controls within a specified Coda document. Supports optional limit and sorting by name. ```APIDOC ## listControls ### Description List controls in a document. ### Method Signature ```typescript export const listControls = ( options: Options ) => { ... } ``` ### Parameters #### Options - `path.docId` (string) - Required - Document ID. - `query.limit` (number) - Optional - Maximum number of results to return. - `query.sortBy` (string) - Optional - Field to sort results by. Accepts "name". ### Returns `ControlList` - A list of controls. ``` -------------------------------- ### Create a Page Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/QUICK-REFERENCE.md Creates a new page within a document, with optional content and parent page specification. ```APIDOC ## coda_create_page ### Description Creates a new page within a document, with optional content and parent page specification. ### Parameters #### Path Parameters - **docId** (string) - Required - The ID of the document. - **name** (string) - Required - The name of the new page. #### Query Parameters - **content** (string) - Optional - The markdown content for the new page. - **parentPageId** (string) - Optional - The ID of the parent page for nesting. ### Returns Created Page ``` -------------------------------- ### Get Coda Table Summary Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Obtain a comprehensive summary of a Coda table, including row count, column details, sample data, and statistics. This operation involves multiple API calls for data collection. ```typescript server.tool( "coda_get_table_summary", "Get a detailed summary of a table including row count and column info", { docId: z.string().describe("The ID of the document containing the table"), tableIdOrName: z.string().describe("The ID or name of the table to summarize"), }, async ({ docId, tableIdOrName }): Promise ) ``` -------------------------------- ### Get Coda Document Statistics Source: https://github.com/dustinrgood/coda-mcp/blob/main/_autodocs/api-reference/mcp-server.md Retrieve statistics and insights for a specific Coda document using its ID. The returned data includes document metadata, aggregated counts, and breakdowns of elements like tables and formulas. ```typescript server.tool( "coda_get_document_stats", "Get statistics and insights about a document", { docId: z.string().describe("The ID of the document to analyze"), }, async ({ docId }): Promise ) ```