Content
# Tool List
[](https://github.com/lcysts1019-bit/mrdoc-mcp-server)
[](LICENSE)
[](https://modelcontextprotocol.io)
**Let Claude Code directly read and write your MrDoc documents.**
MrDoc MCP Server is a server based on [Model Context Protocol (MCP)](https://modelcontextprotocol.io) that exposes the API of [MrDoc](https://github.com/zmister2016/MrDoc) to Claude Code, allowing you to search, read, create, and edit documents directly in conversations.
## Why do I need this project?
If you use both Claude Code and MrDoc, you may encounter scenarios like:
- Wanting Claude to help you write a document, but needing to manually copy and paste to MrDoc
- Wanting Claude to reference existing documents to answer questions, but needing to manually paste the content
- Wanting to update documents in bulk, but finding it tedious to do so one by one
This MCP server solves these problems — Claude Code can interact directly with your MrDoc instance without any manual operations.
## Features
### Document Operations
| Tool | Description | Example Command |
|------|-------------|---------------|
| `search_docs` | Full-text search documents | "Help me search for documents about spray painting" |
| `get_doc` | Get document metadata (title, time, etc.) | "View the basic information of document 42" |
| `get_doc_content` | Get the full content of a document (Markdown) | "Read the content of document 42" |
| `create_doc` | Create a new document | "Create a new document in project 3 with the title XXX" |
| `update_doc` | Update an existing document | "Change the title of document 42 to XXX" |
| `get_self_docs` | Get the list of documents created by the current user | "List all documents I have created" |
### Project Management
| Tool | Description | Example Command |
|------|-------------|---------------|
| `list_projects` | List all knowledge spaces | "List all knowledge spaces" |
| `get_project` | Get project details and directory structure | "View the details of project 3" |
| `list_docs` | List documents under a project (hierarchical structure) | "List all documents under project 3" |
| `get_project_docs` | Get the list of documents in a project (paginated) | "View the documents in project 3 on page 2" |
| `create_project` | Create a new knowledge space | "Create a new knowledge space named 'Technical Documents'" |
### Media Resources
| Tool | Description | Example Command |
|------|-------------|---------------|
| `upload_img` | Upload an image to MrDoc | "Upload this image" |
## Prerequisites
- **Node.js** >= 18.0.0
- **Claude Code** installed ([installation guide](https://docs.anthropic.com/en/docs/claude-code/overview))
- **MrDoc instance** deployed and running ([MrDoc deployment guide](https://github.com/zmister2016/MrDoc))
## Installation
```bash
git clone https://github.com/lcysts1019-bit/mrdoc-mcp-server.git
cd mrdoc-mcp-server
npm install
npm run build
```
## Configuration
### Step 1: Obtain MrDoc API Token
1. Log in to your MrDoc instance
2. Go to Personal Center → Token Management
3. Create a new API token and copy it
### Step 2: Register MCP Server with Claude Code
```bash
claude mcp add mrdoc \
-e MRDOC_BASE_URL=https://your-mrdoc-domain.com \
-e MRDOC_TOKEN=your_api_token_here \
-- node /path/to/mrdoc-mcp-server/dist/index.js
```
> Replace `/path/to/mrdoc-mcp-server` with the actual path to your project.
After registration, environment variables are managed by Claude Code and stored in its configuration file (usually located at `~/.claude.json` or project-level `.claude/settings.json`).
You can view registered MCP servers and their configurations with the following command:
```bash
claude mcp list
```
To modify environment variables, remove and re-add:
```bash
claude mcp remove mrdoc
claude mcp add mrdoc \
-e MRDOC_BASE_URL=https://new-url \
-e MRDOC_TOKEN=new_token \
-- node /path/to/mrdoc-mcp-server/dist/index.js
```
### Environment Variable Description
| Variable | Required | Default Value | Description |
|----------|----------|---------------|-------------|
| `MRDOC_BASE_URL` | No | `http://192.168.9.38:10086` | MrDoc instance access address, without trailing `/` |
| `MRDOC_TOKEN` | **Yes** | - | API authentication token, obtained from MrDoc Personal Center |
| `MRDOC_USERNAME` | No | `admin` | Login username (only used for session authentication, generally not needed) |
| `MRDOC_PASSWORD` | No | `admin` | Login password (only used for session authentication, generally not needed) |
> Usually, only `MRDOC_BASE_URL` and `MRDOC_TOKEN` are needed. `MRDOC_USERNAME` and `MRDOC_PASSWORD` are only used for certain operations that require session authentication, with default values of `admin`.
### Step 3: Verify Configuration
Restart Claude Code and try:
```
List all knowledge spaces
```
If the project list is returned, the configuration is successful.
## Usage Examples
After configuration, you can directly operate documents in Claude Code using natural language:
```
# Search documents
Help me search for documents about spray painting
# Read documents
Read the content of document ID 42 and summarize the main points
# Create documents
Create a new document in project 3 with the title "2024 Technical Summary" and content including...
# Update documents
Append a section about performance optimization to document 42
# Batch operations
Help me add the prefix "[Archived]" to the titles of all documents under project 3
```
## Development
### Local Development
```bash
# Clone repository
git clone https://github.com/lcysts1019-bit/mrdoc-mcp-server.git
cd mrdoc-mcp-server
# Install dependencies
npm install
# Development mode (compile and run)
npm run dev
# Compile only
npm run build
# Clean compiled output
npm run clean
```
### Project Structure
```
src/
index.ts # Entry file, assembling MCP server
config.ts # Environment variable configuration management
client.ts # MrDoc HTTP API client (including authentication logic)
schemas.ts # Zod input validation schema
tools.ts # Definition and processor of 12 MCP tools
types.ts # TypeScript type definitions
```
### Technology Stack
- **Runtime**: Node.js 18+
- **Language**: TypeScript 5.3+ (strict mode)
- **MCP SDK**: `@modelcontextprotocol/sdk` ^1.0.0
- **Validation**: Zod ^3.22.0
- **HTTP**: Native `fetch` API (no additional dependencies)
## FAQs
### Connection Failed
Ensure `MRDOC_BASE_URL` is accessible from your machine. If MrDoc is deployed on a private network, ensure you are in the same network environment.
### Authentication Failed
- Check if `MRDOC_TOKEN` is correct
- Token may have expired, please regenerate in MrDoc
### Tools Not Visible in Claude Code
Ensure Claude Code has been restarted and the MCP server has been registered successfully. You can check with the following command:
```bash
claude mcp list
```
## Contributing
Welcome to submit issues and pull requests!
1. Fork this repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Create a pull request
## License
This project is open-sourced under the MIT license - see [LICENSE](LICENSE) file
## Acknowledgements
- [MrDoc](https://github.com/zmister2016/MrDoc) - Excellent open-source document management system
- [Model Context Protocol](https://modelcontextprotocol.io) - MCP protocol specification
- [Anthropic](https://www.anthropic.com/) - Claude Code and MCP SDK