doc2mcp Python SDK
Python client library for the doc2mcp service that converts documentation into MCP-compliant API endpoints.
Installation
pip install doc2mcp
Quick Start
Authentication
First, authenticate with your doc2mcp server:
from doc2mcp import login
# Login to your doc2mcp instance
login("https://your-doc2mcp-instance.com")
Upload Documentation
from doc2mcp import Doc2MCPClient
# Initialize authenticated client
client = Doc2MCPClient()
# Upload documentation files
project = client.upload_documents(
name="My API Documentation",
files=["./docs/api.md", "./docs/guide.md", "./README.md"],
description="Complete API documentation for my project"
)
print(f"Project created: {project.name}")
print(f"MCP Endpoint: {project.mcp_endpoint}")
print(f"API Token: {project.api_token}")
Search Documents
# Search your documentation
results = client.search(
project_slug=project.slug,
query="authentication setup",
api_token=project.api_token,
limit=5
)
for result in results.results:
print(f"Score: {result.score}")
print(f"Content: {result.content[:200]}...")
List Projects
# Get all your projects
projects = client.get_projects()
for project in projects:
print(f"{project.name} ({project.status}) - {project.file_count} files")
CLI Usage
The SDK includes a command-line interface:
Authentication
# Login
doc2mcp login --server https://your-instance.com
# Check login status
doc2mcp whoami
# Logout
doc2mcp logout
Project Management
# Upload documentation
doc2mcp upload --name "My Docs" --description "API documentation" ./docs/
# List projects
doc2mcp list
# Search in a project
doc2mcp search my-project-slug "authentication"
# Delete a project
doc2mcp delete my-project-slug
API Reference
Client Class
from doc2mcp import Doc2MCPClient
client = Doc2MCPClient(
base_url="https://your-instance.com", # Optional, uses authenticated server
api_key="your-api-key" # Optional, uses stored credentials
)
Methods
upload_documents(name, files, description="")
Upload documentation files and create a new project.
Parameters:
name(str): Project namefiles(List[str]): List of file paths to uploaddescription(str, optional): Project description
Returns: Project object with endpoint details
get_projects()
Get all projects for the authenticated user.
Returns: List of Project objects
get_project(project_id)
Get a specific project by ID.
Parameters:
project_id(int): Project ID
Returns: Project object
delete_project(project_id)
Delete a project and its MCP endpoint.
Parameters:
project_id(int): Project ID to delete
Returns: Boolean indicating success
search(project_slug, query, api_token, limit=10)
Search documents in a project using the MCP endpoint.
Parameters:
project_slug(str): Project slugquery(str): Search queryapi_token(str): API token for authenticationlimit(int, optional): Maximum number of results
Returns: SearchResult object with matching documents
Data Models
Project
@dataclass
class Project:
id: int
name: str
slug: str
description: str
status: str # 'processing', 'ready', 'error'
file_count: int
mcp_endpoint: str
api_token: str
created_at: str
SearchResult
@dataclass
class SearchResult:
results: List[SearchResultItem]
total: int
query: str
@dataclass
class SearchResultItem:
content: str
score: float
metadata: dict
Error Handling
from doc2mcp.exceptions import (
Doc2MCPError,
ProjectNotFoundError,
UploadError,
APIError
)
try:
project = client.upload_documents(
name="My Docs",
files=["./nonexistent.md"]
)
except UploadError as e:
print(f"Upload failed: {e}")
except APIError as e:
print(f"API error: {e}")
Configuration
The SDK stores configuration in ~/.config/doc2mcp/config.json:
{
"server_url": "https://your-instance.com",
"api_key": "your-api-key"
}
Contributing
- Clone the repository
- Install in development mode:
pip install -e . - Run tests:
pytest tests/ - Follow the contribution guidelines in CONTRIBUTING.md
Author
Created by Yacine Zahidi (@ell-hol)
License
MIT License - see LICENSE file for details
Metadata
Release files for doc2mcp 0.0.45
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| doc2mcp-0.0.45.tar.gz | 13.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| doc2mcp-0.0.45-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.5 kB
Release files / doc2mcp-0.0.45.tar.gz
| Download URL | doc2mcp-0.0.45.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf748776362cc2ead7db1b3cf68ee1eb3356c44d9b4ea2053befb8ea8b69287e
|
|
BLAKE2b-256 checksum How to use checksums |
293482fe19715045b0f37f6e33703d8e2d5b5f8608242310e575c4e0d45c5603
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / doc2mcp-0.0.45-py3-none-any.whl
| Download URL | doc2mcp-0.0.45-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c30e203c75472257a0992c58ae68edf7ac52f15982ef2cc87f65945be4a254b
|
|
BLAKE2b-256 checksum How to use checksums |
0459c60ce7d7de128804032d34fa47612a12edf16d841d263a6101728842ada6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for doc2mcp 0.0.45
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.