Skip to content

MCP Server

Overview

ODP includes a built-in Model Context Protocol (MCP) server that enables AI agents and LLMs to interact with ODP data and schema through a standardized tool-calling interface.

The MCP server exposes ODP's data operations (CRUD on collections, schema management, workflow operations) as typed tools that can be discovered and called by any MCP-compatible AI client (Claude, ChatGPT plugins, etc.).


Architecture

ODP implements MCP in two modes:

1. Stateless HTTP (per-request)

POST /server/mcp — A simple endpoint where each request is handled by a fresh MCP Server instance and FastifyTransport. No persistent connection required.

2. Full MCP Protocol (via OdpMCP)

Routes using OdpMCP.handleRequest() implement the full JSON-RPC message protocol per the MCP specification. Each request creates a fresh Server instance and FastifyTransport to avoid connection conflicts with concurrent requests.


Access Control

MCP access requires:

  1. An authenticated request (accountability.user or accountability.admin)
  2. If ENABLE_APP_PERMISSIONS !== 'false': the user must have app permission module = mcp, action = access

Endpoints

POST /server/mcp

Simple tool execution endpoint (non-standard, simpler protocol).

Auth required: Admin access

Request Body:

json
{
  "tool": "items_read",
  "params": {
    "collection": "articles",
    "query": { "limit": 10 }
  }
}

Response:

json
{
  "data": {
    "items": [...]
  }
}

Error response:

json
{
  "error": "Unknown tool: nonexistent_tool"
}

GET /server/mcp/tools

List all available MCP tools with their schemas.

Auth required: Admin access

Response:

json
{
  "data": [
    {
      "name": "items_read",
      "description": "Read items from a collection",
      "parameters": {
        "type": "object",
        "properties": {
          "collection": { "type": "string" },
          "query": { "type": "object" }
        },
        "required": ["collection"]
      }
    }
  ]
}

Available Tools

Items

ToolDescription
items_readRead items from a collection with optional query
items_createCreate a single item
items_updateUpdate a single item by ID
items_deleteDelete a single item
items_create_manyCreate multiple items
items_update_manyUpdate multiple items
items_delete_manyDelete multiple items

Schema

ToolDescription
schema_listList all collections with their fields
schema_readRead schema for a specific collection

Collections

ToolDescription
collections_createCreate a new collection
collections_listList all collections
collections_readRead a collection's metadata
collections_updateUpdate a collection's metadata
collections_deleteDelete a collection

Fields

ToolDescription
fields_createAdd a field to a collection
fields_updateUpdate a field's configuration
fields_deleteRemove a field from a collection

Relations

ToolDescription
relations_createCreate a relation between collections
relations_listList all relations
relations_readRead a specific relation
relations_updateUpdate a relation
relations_deleteDelete a relation

Files

ToolDescription
files_listList files with optional filters
files_readRead a file's metadata by ID

Users

ToolDescription
users_listList users
users_readRead a user by ID

Versions

ToolDescription
versions_listList content versions
versions_readRead a version by ID
versions_promotePromote a version to live content

Activity

ToolDescription
activity_listQuery activity log

Workflow (Definition)

ToolDescription
workflow_createCreate a workflow definition
workflow_listList workflow definitions
workflow_readRead a workflow
workflow_updateUpdate a workflow
workflow_deleteDelete a workflow
workflow_duplicateDuplicate a workflow
workflow_activateActivate a workflow
workflow_deactivateDeactivate a workflow

Workflow Steps & Transitions

ToolDescription
workflow_step_addAdd a step to a workflow
workflow_step_updateUpdate a step
workflow_step_removeRemove a step
workflow_transition_addAdd a transition between steps
workflow_transition_updateUpdate a transition
workflow_transition_removeRemove a transition

Workflow Instances

ToolDescription
workflow_instance_startStart a workflow instance
workflow_instance_listList instances
workflow_instance_readRead an instance
workflow_instance_cancelCancel an instance
workflow_instance_approveApprove a step
workflow_instance_rejectReject a step
workflow_instance_delegateDelegate a step to another user
workflow_instance_commentAdd a comment to an instance

Workflow Tasks

ToolDescription
workflow_tasks_mineGet tasks assigned to current user
workflow_tasks_allGet all pending tasks
workflow_tasks_countCount pending tasks

OdpMCP Configuration

The OdpMCP class accepts an allowDeletes option:

typescript
const mcp = new OdpMCP({ allowDeletes: false });

When allowDeletes = false (default), items_delete and items_delete_many tools are excluded from the tool list. This provides a safety guard for production MCP deployments.


MCPContext

Each tool handler receives a context object:

typescript
interface MCPContext {
  knex: Knex;               // Database connection
  accountability: Accountability | null;  // Caller's permissions
  schema: SchemaOverview;   // Current database schema
  settings: MCPSettings;    // Collection access settings
}

interface MCPSettings {
  allowedCollections: string[] | null;  // null = all collections
  readOnlyCollections: string[] | null; // null = none read-only
}

Example: Using MCP with Claude

json
{
  "mcpServers": {
    "odp": {
      "url": "https://api.example.com/api/mcp",
      "headers": {
        "Authorization": "Bearer <access_token>"
      }
    }
  }
}

Then in Claude:

Use the items_read tool to get the latest 5 published articles from the "articles" collection.

Configuration

VariableDefaultDescription
ENABLE_APP_PERMISSIONStrueSet to false to disable app permission checks

MCP settings are also stored in odp_extension_settings with key system_mcp_settings and can include allowedCollections and readOnlyCollections lists.

ODP Internal API Documentation