The UTCP Documentation MCP Server now includes an OpenAI-powered expert agent that answers questions about UTCP with deep knowledge of the entire specification.
User asks Cursor about UTCP
↓
Cursor calls ask_utcp_expert tool on MCP server
↓
MCP Server's LLM Agent:
1. Searches UTCP docs for relevant context
2. Calls OpenAI API with docs + question
3. Returns expert answer
↓
User gets intelligent response
An AI agent with deep UTCP knowledge that can answer any question about the protocol.
{
"tool": "ask_utcp_expert",
"arguments": {
"question": "How do I authenticate with bearer tokens in HTTP?"
}
}Explanations:
- "What is body_template and when should I use it?"
- "Explain the difference between SSE and streamable_http protocols"
- "What's the purpose of call_template_type?"
How-to:
- "How do I add OAuth2 authentication to my UTCP manual?"
- "How do I reference previous CLI command outputs?"
- "How do I handle large streaming responses?"
Examples:
- "Show me a complete HTTP tool example with authentication"
- "Give me an example of a CLI tool that chains multiple commands"
- "What does a working SSE tool look like?"
Troubleshooting:
- "Why am I getting 401 errors with my bearer token?"
- "My tool name is failing validation, what's wrong?"
- "How do I fix 'body_template required' error?"
The agent returns:
- Detailed answer - Explained clearly with context
- Code examples - When relevant, includes JSON examples
- Sources - Lists which UTCP docs were used
- Best practices - Suggests proper approaches
Example Response:
# Bearer Token Authentication
Bearer tokens are commonly used for OAuth2 and JWT authentication in HTTP APIs.
## Configuration
Add this to your tool's auth section:
```json
{
"auth": {
"auth_type": "bearer",
"token": "${BEARER_TOKEN}"
}
}The bearer token is automatically added to the Authorization header:
Authorization: Bearer your_token_here
- Store tokens in environment variables
- Never commit tokens to code
- Use HTTPS only for bearer auth
- Consider token expiry and refresh
- HTTP Protocol (protocols) - Relevance: 95
- Authentication Guide (guides) - Relevance: 88
- for-tool-providers (guides) - Relevance: 76
## 🔧 Configuration
### Environment Variable
Set your OpenAI API key:
```bash
export OPENAI_API_KEY="sk-your-api-key-here"
# .env
OPENAI_API_KEY=sk-your-api-key-here{
"mcpServers": {
"utcp-docs": {
"command": "node",
"args": ["/path/to/utpc-docs-mcp-server/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-api-key-here"
}
}
}
}When you ask a question, the agent:
- Searches the UTCP documentation for relevant sections
- Retrieves top 5-10 most relevant docs
- Includes up to 2000 characters from each doc
If your question needs examples, it automatically includes:
- Protocol-specific examples (HTTP, CLI, SSE, etc.)
- Authentication examples (if asking about auth)
- Minimal working examples
The agent calls OpenAI's GPT-4 Turbo with:
- System prompt - Makes it a UTCP expert
- Documentation context - Relevant UTCP docs
- Your question - What you asked
Every response includes sources showing which docs were used.
class UtcpAgent {
constructor(
docService: DocumentationService,
generator: UtcpGenerator,
apiKey?: string
)
async ask(question: string): Promise<{
answer: string;
sources: Array<{
title: string;
section: string;
relevance: number;
}>;
}>
}- ✅ No session management (stateless)
- ✅ No complex intent classification
- ✅ No conversation state tracking
- ✅ Simple: question in → answer out
The agent intelligently builds context by:
- Searching docs for your question
- Detecting if examples are needed
- Adding protocol-specific examples
- Adding auth examples if relevant
- Natural Q&A - Ask like talking to an expert
- Accurate Answers - Grounded in actual UTCP docs
- With Examples - Gets relevant code automatically
- Source References - See which docs were used
- Leverages existing search - Uses DocumentationService
- No duplication - Doesn't reimplement anything
- Extensible - Easy to improve prompts
- Cost-effective - Only calls API when needed
| Feature | search_utcp_docs |
ask_utcp_expert |
|---|---|---|
| Input | Keywords | Natural language question |
| Understanding | Keyword matching | Semantic understanding |
| Response | Raw doc excerpts | Explained answer |
| Examples | Must search separately | Included automatically |
| Context | Single query | Multiple docs synthesized |
| Guidance | None | Best practices included |
// Question 1
ask_utcp_expert({
question: "What are the main protocol types in UTCP?"
})
// Gets: Overview of HTTP, CLI, MCP, SSE, Streamable HTTP
// Question 2
ask_utcp_expert({
question: "Show me a complete HTTP tool example with API key auth"
})
// Gets: Full example + explanation + best practices// Question 1
ask_utcp_expert({
question: "I need to create a tool for GitHub's API. What protocol should I use?"
})
// Gets: Recommendation for HTTP protocol + reasoning
// Question 2
ask_utcp_expert({
question: "How do I structure the GitHub API tool with bearer token auth?"
})
// Gets: Complete example + field explanations
// Then use the actual tools
generate_utcp_manual({...})
validate_utcp_manual({...})ask_utcp_expert({
question: "My tool name 'GetData' is failing validation. What's wrong?"
})
// Gets: Explanation of snake_case requirement + how to fix- Stored in environment variables
- Never logged or exposed
- Required for agent to work
- Your questions are sent to OpenAI
- UTCP docs are sent as context
- No personal data unless you include it in questions
- Uses GPT-4 Turbo (~$0.01 per 1K tokens)
- Typical question costs $0.02-0.05
- Monitor usage in OpenAI dashboard
✅ Good:
- "How do I add OAuth2 authentication to an HTTP tool?"
- "Show me an example of a CLI tool with multiple commands"
- "What's the difference between body_template and body_field?"
❌ Less Good:
- "auth?" (too vague)
- "how work" (unclear)
- "example" (need more context)
Add "show me" or "example" to get code:
- "Show me an SSE protocol example"
- "Give me an example of bearer auth"
- "Example of CLI tool with working directory"
The agent has full UTCP context, so you can:
- Ask follow-up questions
- Request deeper explanations
- Get alternative approaches
| Static Docs | LLM Agent |
|---|---|
| Must search & read | Ask directly |
| Find relevant sections manually | Automatic retrieval |
| Piece together info | Synthesized answer |
| No examples | Examples included |
| Simple RAG | LLM Agent |
|---|---|
| Returns chunks | Returns answers |
| User interprets | LLM explains |
| Context limited | Context synthesized |
| No reasoning | Can reason & suggest |
Possible improvements:
- Support for other LLM providers (Anthropic, local models)
- Fine-tuning on UTCP-specific Q&A pairs
- Caching frequent questions
- Multi-turn conversation support
- Code execution to validate examples
Solution: Set the OPENAI_API_KEY environment variable
export OPENAI_API_KEY="sk-..."Reason: GPT-4 Turbo can take 5-10 seconds for detailed answers
Solutions:
- Use GPT-3.5-turbo for faster (but less accurate) responses
- Reduce context size in agent configuration
Reason: Question might be too vague or docs not comprehensive enough
Solutions:
- Ask more specific questions
- Include more context in your question
- Use the simpler search tools for quick lookups
The UTCP Expert Agent transforms the MCP server from a documentation search tool into an intelligent assistant that:
✅ Understands natural language questions
✅ Retrieves relevant UTCP documentation
✅ Synthesizes comprehensive answers
✅ Includes code examples automatically
✅ Explains concepts clearly
✅ Suggests best practices
✅ Sources its answers transparently
All powered by OpenAI, grounded in actual UTCP docs, and accessible through a simple MCP tool!
Try it: ask_utcp_expert({ question: "How does the UTCP agent work?" })