A demonstration of using MCP (Model Context Protocol) to generate documentation from multiple sources.
npm install
cd mcp-server && npm install && cd ..
cd petstore-mcp-server && npm install && cd ..
cd mcp-client && npm install && cd ..
# Test all components
npm run test-workflow
# Run the complete demo
npm run demo
# View the documentation
npm run dev
This project demonstrates a complete MCP workflow for automated documentation generation from multiple sources.
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Starlight │ │ MCP Client │ │ Pet Store │
│ Docs Site │◄───┤ (Orchestrator) │◄───┤ MCP Server │
│ │ │ │ │ │
│ - Guides │ │ - Connects to │ │ - OpenAPI Spec │
│ - Reference │ │ multiple MCP │ │ - API Endpoints │
│ - API Docs │ │ servers │ │ - Data Schemas │
│ - Generated │ │ - Generates docs │ │ - Examples │
└─────────────────┘ └──────────────────┘ └─────────────────┘
This project demonstrates a complete Model Context Protocol (MCP) workflow for automated documentation generation. It consists of three main components:
The StarlightMCPClient serves as the orchestrator that connects to multiple MCP servers and coordinates documentation generation:
Key features:
- Multi-server connectivity: Can connect to multiple MCP servers simultaneously
- Tool execution: Calls tools on remote servers and processes responses
- Resource management: Reads and lists resources from connected servers
- Documentation generation: Automatically generates combined documentation from multiple sources
- File system integration: Writes generated documentation to the Starlight docs structure
Main methods:
connectToServer()
- Establishes connections to MCP serversgenerateApiDocs()
- Generates API documentation from Pet Store servergenerateStarlightDocs()
- Retrieves existing Starlight documentation structuregenerateCombinedDocs()
- Creates unified documentation combining multiple sources
This server provides API documentation tools based on OpenAPI specifications:
Available tools:
get_api_specification
- Returns complete OpenAPI speclist_endpoints
- Lists all API endpoints (filterable by tag)get_endpoint_details
- Gets detailed information about specific endpointsget_schemas
- Retrieves data models and schemasgenerate_markdown_docs
- Generates formatted markdown documentationget_api_info
- Returns basic API metadata
Key capabilities:
- OpenAPI integration: Reads from
petstore-api.json
specification - Flexible output: Supports different documentation formats (full, endpoints, schemas, overview)
- Example generation: Includes request/response examples
- Resource access: Provides access to the raw API specification file
This server manages existing Starlight documentation and provides tools for content discovery:
Available tools:
list_docs
- Lists all documentation pages (filterable by category)search_docs
- Searches documentation content by keywordget_doc_content
- Retrieves specific page content with frontmatterget_site_structure
- Returns complete site navigation structure
Key capabilities:
- Content discovery: Scans the
src/content/docs/
directory - Frontmatter processing: Extracts metadata from markdown files
- Search functionality: Full-text search across documentation
- Structure analysis: Provides site navigation and organization
- Resource access: Lists and reads documentation files
The typical workflow follows this pattern:
- Client initialization: MCP client starts and prepares to connect to servers
- Server connections: Client connects to both Pet Store and Starlight MCP servers
- Content retrieval:
- Pet Store server provides API documentation from OpenAPI spec
- Starlight server provides existing documentation structure
- Documentation generation: Client combines content and generates unified documentation
- File output: Generated documentation is written to
src/content/docs/
- Cleanup: Client disconnects from all servers
- Modular design: Each server has a specific responsibility
- Extensible: Easy to add new MCP servers for different content sources
- Automated: Documentation generation can be integrated into CI/CD pipelines
- Standards-based: Uses the official MCP SDK and protocol
- Content-aware: Understands both API specs and existing documentation
Command | Action |
---|---|
npm install |
Installs dependencies |
npm run dev |
Starts local dev server at localhost:4321 |
npm run build |
Build your production site (includes doc generation) |
npm run preview |
Preview your build locally, before deploying |
npm run demo |
Run the complete MCP workflow demo |
npm run test-workflow |
Test all MCP components |
npm run generate-docs |
Generate documentation from MCP servers |
npm run demo-petstore |
Test Pet Store MCP server only |
npm run demo-starlight |
Test Starlight MCP server only |
.
├── mcp-server/ # Starlight MCP server
├── petstore-mcp-server/ # Pet Store API MCP server
├── mcp-client/ # MCP client orchestrator
├── src/content/docs/ # Generated documentation
├── test-workflow.js # Workflow test script
└── MCP-DEMO-WORKFLOW.md # Detailed documentation
After running the demo, you'll find:
- API documentation:
src/content/docs/api/petstore-api.md
- Updated index:
src/content/docs/index.mdx
- MCP Demo Workflow Guide - Detailed documentation
- Starlight Documentation
- Model Context Protocol
Check out Starlight's docs, read the Astro documentation, or jump into the Astro Discord server.