ktme includes a complete MCP (Model Context Protocol) server that allows you to integrate automated documentation generation directly with Claude Code and other AI assistants.
- What: Saves documentation as Markdown files on your local filesystem
- Where:
./docs/{service}_{type}.md - Use case: Perfect for personal projects, local development, version-controlled documentation
- Advantages:
- ✅ No external dependencies
- ✅ Files tracked in Git
- ✅ Full control over content
- ✅ Easy to edit and maintain
- Status: Fully implemented with HTTP and STDIO transport support
- What: Publishes documentation directly to Confluence pages
- Where: Your Confluence workspace
- Use case: Enterprise teams, knowledge management, shared documentation
- Advantages:
- ✅ Enterprise-ready knowledge base
- ✅ Team collaboration features
- ✅ Access controls and permissions
- ✅ Rich formatting and attachments
- Status: Infrastructure ready, implementation pending
- HTTP/SSE Transport - Full JSON-RPC 2.0 support on port 3000
GET /status- Server health and statisticsPOST /shutdown- Graceful server shutdownPOST /mcp- JSON-RPC 2.0 endpoint for all MCP methods
- STDIO Transport - Direct integration with Claude Code and MCP clients
- Server State Management - Graceful shutdown with cleanup
- Protocol Handler - Complete MCP 2024-11-05 protocol implementation
read_changes- Extract code changes from Gitget_service_mapping- Get documentation location for a servicelist_services- List all mapped servicesgenerate_documentation- AI-powered documentation generationupdate_documentation- Update existing documentationsearch_services- Search services by namesearch_by_feature- Search by feature namesearch_by_keyword- Keyword-based searchautomated_documentation_workflow- End-to-end workflowdetect_service_name- Auto-detect service from changesget_repository_info- Get repository metadata
- Multi-provider Support - OpenAI, Claude (Anthropic), Mock provider
- Async Runtime - Tokio-based async/await for performance
- Error Handling - Robust fallbacks and error reporting
- ✅ Unit tests for protocol handler (6/6 passing)
- ✅ Integration tests for STDIO mode (2/2 passing)
- ✅ HTTP endpoint testing (all 3 endpoints verified)
- ✅ End-to-end workflow tested
- Confluence Cloud integration
- Template system for custom documentation formats
- Knowledge graph and RAG search capabilities
# Build the project
cargo build --release
# Install globally (optional)
cargo install --path .# Start HTTP daemon on port 3000
ktme mcp start --daemon
# Output:
# 🚀 ktme MCP server started in daemon mode on http://localhost:3000
# 💡 Add to Claude Code: mcp://localhost:3000# Start in STDIO mode
ktme mcp start
# Output:
# 🚀 ktme MCP server started in STDIO mode
# 💡 Ready for Claude Code integrationThe MCP server automatically detects AI providers from environment variables:
export OPENAI_API_KEY="sk-your-openai-key"
export OPENAI_MODEL="gpt-4" # Optionalexport ANTHROPIC_API_KEY="sk-ant-your-claude-key"
export CLAUDE_MODEL="claude-3-sonnet-20240229" # Optional# Check server status
ktme mcp status
# Stop the server
ktme mcp stop-
Start the MCP server in daemon mode:
ktme mcp start --daemon
-
Add to Claude Code:
- Open Claude Code settings
- Go to MCP Servers
- Add new server:
mcp://localhost:3000 - Server will auto-discover available tools
- Add to Claude Code:
- Open Claude Code settings
- Go to MCP Servers
- Add new server:
/path/to/ktme mcp start - Use full path to ktme binary
Create or edit ~/.config/claude-code/mcp_servers.json:
{
"ktme": {
"command": "/path/to/ktme",
"args": ["mcp", "start", "--config", "/path/to/config.toml"],
"env": {
"OPENAI_API_KEY": "your-api-key"
}
}
}The ktme MCP server provides these tools that you can use directly in Claude Code:
Extract code changes from Git commits, PRs, or staged changes.
{
"name": "extract_changes",
"description": "Extract code changes from Git",
"parameters": {
"source": "commit|pr|staged",
"identifier": "commit-hash|pr-number|staged",
"provider": "github|gitlab|bitbucket"
}
}Example Usage:
Extract the changes from the latest commit
Generate documentation from code changes using AI.
{
"name": "generate_documentation",
"description": "Generate AI-powered documentation",
"parameters": {
"service": "service-name",
"doc_type": "changelog|api-doc|readme|general",
"provider": "markdown|confluence",
"format": "markdown|json"
}
}Example Usage:
Generate documentation for the authentication service as a changelog in markdown format
Read previously extracted changes from a file.
{
"name": "read_changes",
"description": "Read extracted changes from file",
"parameters": {
"file_path": "/path/to/diff.json"
}
}Example Usage:
Read the changes from /tmp/latest_changes.json
Claude: Extract the changes from the latest commit and generate a changelog for the user-service
This will:
- ✅ Extract latest Git changes
- ✅ Generate AI-powered changelog
- ✅ Save as
docs/user-service_changelog.md
Claude: Generate API documentation for the payment service using the staged changes, save as markdown
This will:
- ✅ Extract staged changes
- ✅ Generate comprehensive API documentation
- ✅ Save as
docs/payment-service_api-doc.md
Claude: Read changes from /tmp/pr_123_changes.json and create documentation for the analytics service
This will:
- ✅ Load changes from file
- ✅ Generate documentation for analytics service
- ✅ Save as
docs/analytics-service_general.md
You can create a custom configuration file:
# ktme-config.toml
[mcp]
server_name = "my-ktme-server"
transport = "http" # or "stdio"
port = 3000
[ai]
# Auto-detected from environment variables
# provider = "openai" # or "anthropic"
[documentation]
default_provider = "markdown"
default_format = "markdown"
base_path = "./docs"
[logging]
level = "info"# Start with custom config
ktme mcp start --config ./ktme-config.toml --daemon# Check if port is already in use
lsof -i :3000
# Kill existing process
kill -9 <pid>
# Try different port
ktme mcp start --daemon --config <(echo '[mcp]\nport = 3001')# Check environment variables
env | grep -E "(OPENAI|ANTHROPIC)_API_KEY"
# Test AI client directly
ktme generate --service test --doc-type general-
Check server is running:
ktme mcp status
-
Test connectivity:
curl http://localhost:3000/status
-
Check Claude Code logs for connection errors
- Check AI provider is configured
- Check server has write permissions to docs directory
- Look at server logs for error messages
# Enable debug logging
export KTME_LOG_LEVEL=debug
ktme mcp start --daemon# Start server with debug logging
export KTME_LOG_LEVEL=debug
export OPENAI_API_KEY="your-key"
ktme mcp start --daemon
# Monitor logs
tail -f ~/.local/share/ktme/logs/server.log- Use Confluence provider for shared knowledge
- Set consistent naming conventions
- Configure proper access controls
- Use HTTP transport for multiple clients
- Cache generated documentation
- Batch process multiple changes
- Store API keys in environment variables
- Use HTTPS for remote connections
- Rotate API keys regularly
Create custom prompt templates in ~/.config/ktme/templates/:
<!-- custom_changelog.md -->
# {{SERVICE}} Changes
## What's New
{{CHANGE_SUMMARY}}
## Technical Details
{{TECHNICAL_DETAILS}}
## Impact
{{USER_IMPACT}}Create automation scripts for repetitive tasks:
#!/bin/bash
# auto-docs.sh
# Extract changes and generate docs for all services
for service in user-service payment-service auth-service; do
echo "Generating docs for $service..."
ktme generate --service "$service" --doc-type changelog
ktme generate --service "$service" --doc_type api-doc
done
echo "Documentation generation complete!"Add to your CI pipeline:
# .github/workflows/docs.yml
name: Generate Documentation
on:
push:
branches: [main]
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Build ktme
run: cargo build --release
- name: Generate Documentation
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
./target/release/ktme generate --service myapp --doc-type changelog
- name: Commit Documentation
run: |
git add docs/
git commit -m "docs: auto-generated documentation"
git push- Slack Integration: Post documentation to Slack channels
- Teams Integration: Publish to Microsoft Teams
- Wiki.js Support: Alternative to Confluence
- Analytics: Documentation usage metrics
- Multi-language Support: Documentation in different languages
- Version Management: Track documentation versions
If you encounter issues:
- Check this guide first
- Look at the GitHub Issues
- Create detailed bug reports with logs
- Join our Discord Community
Happy documenting! 🎉