AI-SmartTalk/docusaurus-MCP-server
If you are the rightful owner of docusaurus-MCP-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Docusaurus MCP Server is a comprehensive solution for managing Docusaurus documentation using the Model Context Protocol.
create_document
Create a new documentation entry with title and content.
update_docs
Update specific lines in an existing document.
continue_docs
Append content to a document and remove incomplete markers.
get_docs
Retrieve the content of a document by path.
unfinished_docs
List all documents marked as incomplete.
search_docs
Perform semantic search across documentation embeddings.
get_sitemap
Generate a hierarchical view of the documentation structure.
apply_style
Apply style transformations to markdown content.
get_styles
List available style transformations.
health_check
Check service health and status.
metrics
Get service metrics (uptime, requests, document count).
sync_docs
Sync all documents in the docs directory to the vector store.
Docusaurus MCP Server
A comprehensive Model Context Protocol (MCP) server for Docusaurus documentation management, built with TypeScript and the MCP SDK. This server provides the same functionality as the Python MCP-Docusaurus application.
Features
This server provides comprehensive documentation management capabilities including:
- Document Management: Create, read, update, and continue writing documentation
- Vector Search: Semantic search across documentation using embeddings
- Sitemap Generation: Hierarchical view of documentation structure
- Style Transformations: Apply various formatting styles to content
- Health Monitoring: Service health checks and metrics
- Incomplete Document Tracking: Track and manage unfinished documentation
Available Tools
Document Management
create_document
- Create a new documentation entry with title and contentupdate_docs
- Update specific lines in an existing documentcontinue_docs
- Append content to a document and remove incomplete markersget_docs
- Retrieve the content of a document by pathunfinished_docs
- List all documents marked as incomplete
Search & Discovery
search_docs
- Perform semantic search across documentation embeddingsget_sitemap
- Generate a hierarchical view of the documentation structure
Content Transformation
apply_style
- Apply style transformations to markdown contentget_styles
- List available style transformations
System Management
health_check
- Check service health and statusmetrics
- Get service metrics (uptime, requests, document count)sync_docs
- Sync all documents in the docs directory to the vector store
Installation
npm install
Configuration
Environment Variables
DOCS_DIR
- Path to the Docusaurus docs directory (default:../aismarttalk-docs/docs
)OPENAI_API_KEY
- OpenAI API key for embeddings (optional, falls back to simple text features)
Building
npm run build
Running the Server
Option 1: stdio Transport
For command-line integration and testing:
npm run stdio
This starts the server using stdin/stdout for communication, suitable for:
- Command-line MCP clients
- Development and testing
- Integration with tools that support stdio
Option 2: Stateless HTTP Transport
For web-based integration:
npm run http
This starts the server on port 3000 (or PORT environment variable) with:
- RESTful HTTP endpoint at
/mcp
- Health check at
/health
- Server info at
/
- CORS enabled for browser clients
- No session management (stateless)
Embeddings
The server supports two embedding approaches:
-
OpenAI Embeddings (Recommended):
- Set
OPENAI_API_KEY
environment variable - Uses
text-embedding-ada-002
model - High-quality semantic search
- Set
-
Simple Text Features (Fallback):
- Used when OpenAI API key is not available
- Basic word frequency and position features
- Still provides reasonable search functionality
Available Style Transformations
bold_headers
- Make all headers boldadd_spacing
- Add extra spacing between linesremove_comments
- Remove HTML comments from contentclean_whitespace
- Clean up trailing whitespace and normalize newlinesadd_toc
- Generate and add a table of contentsformat_code_blocks
- Clean up code block formattinghighlight_notes
- Highlight Note/Warning/Important sections
Development
# Build and run
npm run dev
Architecture
The server is structured with:
src/server.ts
- Core server implementation with all toolssrc/types.ts
- TypeScript type definitionssrc/embeddings.ts
- Embedding generation (OpenAI + fallback)src/vector-store.ts
- In-memory vector storage and searchsrc/document-manager.ts
- File system operations and document managementsrc/sitemap.ts
- Documentation structure generationsrc/styles.ts
- Content style transformationssrc/metrics.ts
- Health monitoring and metricssrc/stdio.ts
- stdio transport implementationsrc/http.ts
- Stateless HTTP transport implementationsrc/index.ts
- Main entry point and exports
Transport Details
stdio Transport
- Uses standard input/output for communication
- Suitable for CLI tools and direct integration
- No network dependencies
Stateless HTTP Transport
- Each request creates a new server instance
- No session state maintained between requests
- Suitable for horizontally scalable deployments
- CORS-enabled for browser clients
Testing
Using the Makefile
The project includes a comprehensive Makefile for testing the HTTP server.
Requirements: curl
, jq
, and a bash shell.
Note: The MCP server uses Server-Sent Events (SSE) format for responses, which requires a special parser script that's automatically generated.
# See all available commands
make help
# Build and start server for testing
make build
make start-http
# Run all tests
make test-all
# Test individual endpoints
make test-info # Test GET / endpoint
make test-health # Test GET /health endpoint
make test-mcp-init # Test MCP initialization
make test-list-tools # Test listing tools
make test-search-docs # Test document search
make test-create-doc # Test document creation
make test-get-sitemap # Test sitemap generation
make test-health-check # Test health check tool
make test-metrics # Test metrics tool
# Test error handling
make test-error-handling
make test-invalid-methods
# Run a proper MCP client sequence
make test-sequence
# Performance testing
make test-performance
# Clean up
make stop-server
make clean
Quick Demo
For a complete demonstration of all features:
./demo.sh
This script will build the project, start the server, run various tests, and clean up automatically.
Manual Testing
You can also test the server using the MCP Inspector or by implementing a simple MCP client.
Example Usage
Document Management Workflow
-
Create a new document:
{ "tool": "create_document", "arguments": { "path": "api/new-endpoint.md", "title": "New API Endpoint", "content": "This endpoint provides...", "mark_incomplete": true } }
-
Search for related content:
{ "tool": "search_docs", "arguments": { "query": "API authentication methods", "top_k": 5 } }
-
Continue writing the document:
{ "tool": "continue_docs", "arguments": { "path": "api/new-endpoint.md", "continuation": "## Authentication\n\nThis endpoint requires..." } }
-
Apply style transformations:
{ "tool": "apply_style", "arguments": { "style_id": "add_toc", "content": "# My Document\n\n## Section 1..." } }
HTTP Endpoints
When running the HTTP server:
GET /
- Server informationGET /health
- Health checkPOST /mcp
- MCP protocol endpointGET /mcp
- Returns 405 (not supported in stateless mode)DELETE /mcp
- Returns 405 (not supported in stateless mode)
Comparison with Python Version
This TypeScript implementation provides the same functionality as the Python MCP-Docusaurus application:
Feature | Python Version | TypeScript Version |
---|---|---|
Document CRUD | ✅ FastAPI + SQLAlchemy | ✅ fs-extra + vector store |
Vector Search | ✅ PostgreSQL + pgvector | ✅ In-memory + cosine similarity |
Embeddings | ✅ sentence-transformers | ✅ OpenAI API + fallback |
Health/Metrics | ✅ FastAPI endpoints | ✅ MCP tools |
Style Transforms | ✅ Python functions | ✅ TypeScript functions |
Sitemap Generation | ✅ File system traversal | ✅ File system traversal |
License
MIT