The Docmost Model Context Protocol (MCP) Bridge enables AI assistants like Claude to directly interact with the Docmost documentation platform. It implements the Model Context Protocol standard to provide a consistent interface for AI models to discover and use Docmost's capabilities.
The Model Context Protocol (MCP) is a standardized interface that allows AI models to:
- Discover available tools and their capabilities
- Understand parameter requirements for each tool
- Call tools with appropriate parameters
- Process tool responses in a consistent format
The Docmost MCP implementation consists of three main components:
The MCP Bridge acts as an adapter between AI assistants and the Docmost API:
┌─────────────┐ ┌───────────────┐ ┌─────────────┐
│ │ │ │ │ │
│ AI Assistant│<────>│ MCP Bridge │<────>│ Docmost API │
│ │ │ │ │ │
└─────────────┘ └───────────────┘ └─────────────┘
(Claude) (MCP Server) (JSON-RPC API)
A JSON-RPC 2.0 API that provides a uniform interface to all Docmost functionality.
Real-time event system that notifies clients about changes made through the MCP API.
- Node.js 16 or higher
- A Docmost instance with API key support
- An MCP-compatible AI assistant (like Claude)
- Clone this repository
- Install dependencies:
npm install - Create a
.env.mcpfile with the following variables:MCP_SERVER_URL=https://your-docmost-instance.com MCP_API_KEY=your_api_key MCP_WORKSPACE_ID=your_workspace_id MCP_DEBUG=false - Run the MCP bridge:
npm start
The MCP bridge exposes the following tool categories:
-
Space Management:
space_create: Create a new spacespace_list: List spaces in a workspacespace_update: Update a spacespace_delete: Delete a space
-
Page Management:
page_create: Create a new pagepage_list: List pages in a spacepage_update: Update a pagepage_delete: Delete a pagepage_move: Move a page to a different parent or space
-
Comment Management:
comment_create: Create a commentcomment_list: List comments on a pagecomment_update: Update a commentcomment_delete: Delete a comment
-
Attachment Management:
attachment_upload: Upload a file attachmentattachment_list: List attachments for a pageattachment_get: Get attachment detailsattachment_download: Download an attachmentattachment_delete: Delete an attachment
user_list: List users in a workspaceuser_get: Get a user's detailsuser_update: Update a user
group_create: Create a user groupgroup_list: List groups in a workspacegroup_update: Update a groupgroup_delete: Delete a groupgroup_addMember: Add a user to a groupgroup_removeMember: Remove a user from a group
workspace_create: Create a workspaceworkspace_list: List workspacesworkspace_update: Update a workspaceworkspace_delete: Delete a workspaceworkspace_addMember: Add a member to a workspaceworkspace_removeMember: Remove a member from a workspace
ui_navigate: Navigate to a specific destination in the UI
The MCP implementation includes a WebSocket component for real-time updates:
- Server Gateway: Broadcasts events for MCP operations
- Client Hook: Connects to the WebSocket server and updates UI based on events
Events are categorized by resource type and operation:
export enum MCPEventType {
// Space events
SPACE_CREATED = 'space.created',
SPACE_UPDATED = 'space.updated',
SPACE_DELETED = 'space.deleted',
// Page events
PAGE_CREATED = 'page.created',
PAGE_UPDATED = 'page.updated',
PAGE_DELETED = 'page.deleted',
PAGE_MOVED = 'page.moved',
// Comment events
COMMENT_CREATED = 'comment.created',
COMMENT_UPDATED = 'comment.updated',
COMMENT_DELETED = 'comment.deleted',
// UI events
UI_NAVIGATE = 'ui.navigate',
}AI assistants like Claude can use the MCP Bridge to interact with Docmost:
// Example: AI assistant creating a new page via MCP
const result = await callTool("page_create", {
title: "Meeting Notes",
content: {
type: "doc",
content: [
{
type: "paragraph",
content: [{ type: "text", text: "These are the meeting notes." }]
}
]
},
spaceId: "space-123",
workspaceId: "workspace-456"
});
// Result contains the created page information
console.log("Created page:", JSON.parse(result.content[0].text));You can also use the Docmost JSON-RPC API directly:
// Example: Creating a new page via direct API call
const mcpRequest = {
jsonrpc: "2.0",
method: "page.create",
params: {
spaceId: "space-123",
workspaceId: "workspace-456",
title: "My New Page",
content: {
type: "doc",
content: [
{
type: "paragraph",
content: [{ type: "text", text: "This is the content of my new page" }]
}
]
}
},
id: "request-1"
};
// Sending the request with API key authentication
const response = await fetch("https://your-docmost-instance.com/api/mcp", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer your_api_key"
},
body: JSON.stringify(mcpRequest)
});
const result = await response.json();
// result.result will contain the created page informationThe MCP Bridge uses API key authentication to securely connect to the Docmost API:
- Create an API key in your Docmost workspace settings or via the API
- Set the
MCP_API_KEYenvironment variable - The bridge automatically includes the API key in all requests
- Enhanced Tool Descriptions: Improve parameter descriptions for better AI understanding
- Context Gathering: Enhance context for AI operations
- Error Handling: More specific error messages and better error reporting
- Schema Improvements: Consolidate schema definitions
- Code Organization: Split large files into modules and standardize parameter handling
Contributions to the Docmost MCP Bridge are welcome! Please check the existing issues or create new ones to discuss potential improvements.
The MCP implementation is part of the Docmost project and follows the same licensing terms.