Skip to content

Commit ce77a89

Browse files
committed
init p2
1 parent 05d9b89 commit ce77a89

File tree

9 files changed

+1514
-0
lines changed

9 files changed

+1514
-0
lines changed

README.md

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# MCP Docs Server
2+
3+
A simple way to make your documentation files available to AI assistants like Claude.
4+
5+
## What Does This Do?
6+
7+
Think of this as a **library catalog for your documentation**. You have a bunch of markdown files (`.md` files) with documentation, guides, or notes. This server:
8+
9+
1. Finds all your markdown files automatically
10+
2. Makes them available to AI tools through something called MCP (Model Context Protocol)
11+
3. Lets AI assistants search through and read your documentation
12+
13+
It's like giving Claude or other AI tools a filing cabinet of your documentation that they can open and read whenever they need information.
14+
15+
## How It Works (Simple Explanation)
16+
17+
1. **You put documentation files in folders** - Just save your `.md` files in organized folders
18+
2. **The server finds them automatically** - No need to manually register each file
19+
3. **AI can read them** - AI assistants can now access and search your documentation
20+
21+
### Real Example
22+
23+
Let's say you have documentation for "Service 1" with these files:
24+
- `user-functions.md` - How user features work
25+
- `call-functions.md` - How calling features work
26+
- `calendar-functions.md` - How calendar features work
27+
28+
You would organize them like this:
29+
30+
```
31+
docs/
32+
└── service-1/
33+
├── user-functions.md
34+
├── call-functions.md
35+
└── calendar-functions.md
36+
```
37+
38+
That's it! The server will automatically find these files and make them available as:
39+
- `docs://service-1/user-functions`
40+
- `docs://service-1/call-functions`
41+
- `docs://service-1/calendar-functions`
42+
43+
## Quick Start (Step by Step)
44+
45+
### Step 1: Install Python Requirements
46+
47+
You need Python 3.10 or newer and `uv` (a Python package manager) installed.
48+
49+
Install `uv` if you don't have it:
50+
```bash
51+
curl -LsSf https://astral.sh/uv/install.sh | sh
52+
```
53+
54+
Then install the required package:
55+
56+
```bash
57+
uv pip install mcp
58+
```
59+
60+
### Step 2: Add Your Documentation Files
61+
62+
Put your markdown files in the `docs/` folder. Organize them in subfolders by topic or service:
63+
64+
```
65+
docs/
66+
├── service-1/
67+
│ ├── user-functions.md
68+
│ ├── call-functions.md
69+
│ └── calendar-functions.md
70+
├── service-2/
71+
│ └── api-guide.md
72+
└── getting-started/
73+
└── introduction.md
74+
```
75+
76+
The subfolder name (like `service-1`) becomes the category.
77+
78+
### Step 3: Connect to Claude Code
79+
80+
The easiest way is to use the Claude Code CLI. From this project folder, run:
81+
82+
```bash
83+
claude mcp add --transport stdio docs -- uv run python /full/path/to/mcp-example/src/mcp_docs_server.py
84+
```
85+
86+
Replace `/full/path/to/mcp-example` with your actual project path.
87+
88+
Verify it's connected:
89+
90+
```bash
91+
claude mcp list
92+
```
93+
94+
You should see: `docs: ... - ✓ Connected`
95+
96+
That's it! Claude Code can now access your documentation.
97+
98+
## Adding New Documentation
99+
100+
To add new documentation at any time:
101+
102+
1. Create a new `.md` file in the appropriate folder under `docs/`
103+
2. That's it! The server finds new files automatically
104+
105+
For example, to add documentation for a new service:
106+
107+
```
108+
docs/
109+
└── service-3/ # Create new folder
110+
└── setup.md # Add your documentation file
111+
```
112+
113+
No need to restart the server or change any code.
114+
115+
## Using with Claude Code
116+
117+
If you're using Claude Code (the CLI tool), follow Step 3 above. The server is already configured and running!
118+
119+
You can now ask Claude Code questions like:
120+
- "List all available docs resources"
121+
- "Read the service-1/user-functions documentation"
122+
- "Search the docs for authentication"
123+
124+
Claude Code will automatically access your documentation files.
125+
126+
### Managing the Server
127+
128+
Check if the server is connected:
129+
```bash
130+
claude mcp list
131+
```
132+
133+
Remove the server:
134+
```bash
135+
claude mcp remove docs
136+
```
137+
138+
Re-add the server if needed:
139+
```bash
140+
claude mcp add --transport stdio docs -- uv run python /full/path/to/mcp-example/src/mcp_docs_server.py
141+
```
142+
143+
## Connecting to Claude Desktop
144+
145+
To make your documentation available in Claude Desktop:
146+
147+
1. Find your Claude Desktop config file:
148+
- **Mac**: `~/Library/Application Support/Claude/claude_desktop_config.json`
149+
- **Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
150+
151+
2. Open the file and add this (replace `/path/to/mcp-example` with your actual folder path):
152+
153+
```json
154+
{
155+
"mcpServers": {
156+
"docs": {
157+
"command": "python",
158+
"args": ["/path/to/mcp-example/src/mcp_docs_server.py"]
159+
}
160+
}
161+
}
162+
```
163+
164+
## Learn More
165+
166+
- [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk) - Build your own MCP servers
167+
- [MCP Documentation](https://modelcontextprotocol.io) - Learn about Model Context Protocol
168+
- [MCP Python SDK Docs](https://modelcontextprotocol.github.io/python-sdk/) - Complete SDK reference

docs/api/resources.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Resources
2+
3+
The MCP Docs Server exposes documentation files as resources.
4+
5+
## Resource URI Format
6+
7+
Resources use the following URI format:
8+
9+
```
10+
docs://{category}/{name}
11+
```
12+
13+
Where:
14+
- `category`: The subdirectory name (e.g., "getting-started", "api", "examples")
15+
- `name`: The filename without the `.md` extension
16+
17+
## Example Resources
18+
19+
- `docs://getting-started/introduction`
20+
- `docs://getting-started/installation`
21+
- `docs://api/resources`
22+
- `docs://api/tools`
23+
24+
## Listing Resources
25+
26+
Use the MCP `resources/list` method to discover all available documentation resources.
27+
28+
## Reading Resources
29+
30+
Use the MCP `resources/read` method with a resource URI to get the markdown content.
31+
32+
## Dynamic Discovery
33+
34+
The server automatically discovers new markdown files when you call `resources/list`. Just add a new `.md` file to the docs directory and it will be available immediately!

docs/api/tools.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Tools
2+
3+
The MCP Docs Server provides tools for searching and working with documentation.
4+
5+
## search_docs
6+
7+
Search through all documentation files for a given query.
8+
9+
### Parameters
10+
11+
- `query` (string, required): The search term to find in documentation
12+
- `category` (string, optional): Filter results to a specific category
13+
14+
### Example Usage
15+
16+
```json
17+
{
18+
"query": "installation",
19+
"category": "getting-started"
20+
}
21+
```
22+
23+
### Returns
24+
25+
A list of matching documents with excerpts showing where the query appears.
26+
27+
### Search Behavior
28+
29+
- Case-insensitive search
30+
- Searches through entire file content
31+
- Returns up to 5 matching lines per document
32+
- Shows line numbers for context
33+
34+
## Future Tools
35+
36+
Planned tools for future versions:
37+
38+
- `get_doc_metadata`: Get metadata about a documentation file
39+
- `list_categories`: List all available categories
40+
- `validate_links`: Check for broken internal links

docs/examples/basic-usage.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Basic Usage Examples
2+
3+
This document provides examples of how to use the MCP Docs Server.
4+
5+
## Example 1: Listing All Documentation
6+
7+
Request all available resources:
8+
9+
```python
10+
# Using the MCP client
11+
resources = await client.list_resources()
12+
13+
for resource in resources:
14+
print(f"{resource.uri}: {resource.name}")
15+
```
16+
17+
Output:
18+
```
19+
docs://getting-started/introduction: getting-started/introduction
20+
docs://getting-started/installation: getting-started/installation
21+
docs://api/resources: api/resources
22+
docs://api/tools: api/tools
23+
```
24+
25+
## Example 2: Reading a Document
26+
27+
Read the content of a specific document:
28+
29+
```python
30+
content = await client.read_resource("docs://getting-started/introduction")
31+
print(content)
32+
```
33+
34+
## Example 3: Searching Documentation
35+
36+
Search for specific content:
37+
38+
```python
39+
results = await client.call_tool(
40+
"search_docs",
41+
{
42+
"query": "installation",
43+
"category": "getting-started"
44+
}
45+
)
46+
47+
print(results)
48+
```
49+
50+
## Example 4: Adding New Documentation
51+
52+
Simply create a new markdown file:
53+
54+
```bash
55+
# Create a new category
56+
mkdir -p docs/tutorials
57+
58+
# Add a new document
59+
echo "# My Tutorial" > docs/tutorials/my-tutorial.md
60+
```
61+
62+
The server will automatically discover it on the next `list_resources` call!
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Installation
2+
3+
## Prerequisites
4+
5+
- Python 3.10 or higher
6+
- pip or uv package manager
7+
8+
## Install Dependencies
9+
10+
Using pip:
11+
12+
```bash
13+
pip install mcp
14+
```
15+
16+
Using uv:
17+
18+
```bash
19+
uv pip install mcp
20+
```
21+
22+
## Running the Server
23+
24+
From the project root:
25+
26+
```bash
27+
python src/mcp_docs_server.py
28+
```
29+
30+
Or make it executable:
31+
32+
```bash
33+
chmod +x src/mcp_docs_server.py
34+
./src/mcp_docs_server.py
35+
```
36+
37+
## Configuration
38+
39+
The server automatically looks for markdown files in the `docs/` directory relative to the project root. No additional configuration needed!
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Introduction
2+
3+
Welcome to the MCP Docs Server documentation!
4+
5+
This server dynamically discovers and serves markdown documentation files as MCP resources.
6+
7+
## Features
8+
9+
- **Dynamic Discovery**: Automatically finds all `.md` files in the docs directory
10+
- **Categorized Resources**: Organizes documentation by directory structure
11+
- **Search Capability**: Built-in search tool to find content across all docs
12+
- **Easy to Extend**: Just add new markdown files to the docs directory
13+
14+
## Getting Started
15+
16+
1. Install the dependencies
17+
2. Add your markdown files to the `docs/` directory
18+
3. Run the server
19+
4. Connect with an MCP client
20+
21+
That's it!

pyproject.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[project]
2+
name = "mcp-docs-server"
3+
version = "0.1.0"
4+
description = "MCP server that dynamically serves markdown documentation"
5+
authors = [
6+
{name = "Your Name", email = "[email protected]"}
7+
]
8+
readme = "README.md"
9+
requires-python = ">=3.10"
10+
dependencies = [
11+
"mcp>=1.0.0",
12+
]
13+
14+
[project.optional-dependencies]
15+
dev = [
16+
"pytest>=7.0.0",
17+
"pytest-asyncio>=0.21.0",
18+
]
19+
20+
[build-system]
21+
requires = ["hatchling"]
22+
build-backend = "hatchling.build"
23+
24+
[tool.hatch.build.targets.wheel]
25+
packages = ["src"]

0 commit comments

Comments
 (0)