This document explains how MCP (Model Context Protocol) servers work in DecypherTek AI, so you (the AI assistant) can understand and use them effectively.
All MCP servers are registered in mcp-registry.json
. This JSON file tells you:
- Which servers are available
- Which servers are enabled
- What tools each server provides
- How to invoke them
{
"enabled": true, // Can you use this server?
"auto_start": true, // Does it start automatically?
"status": "running" // Current state: "running", "stopped", or "error"
}
{
"tools": [
{
"name": "search",
"description": "Search the web",
"required_params": ["query"],
"optional_params": ["num_results"]
}
]
}
# Before using a server, check mcp-registry.json
servers = load_json("mcp-registry.json")
if servers["servers"]["web-search"]["enabled"]:
# You can use this server!
# Example: Web search
result = await mcp_manager.execute_tool(
server_id="web-search",
tool_name="search",
params={
"query": "Python async programming",
"num_results": 5
}
)
# The server returns structured data
for item in result:
print(f"Title: {item['title']}")
print(f"URL: {item['url']}")
print(f"Snippet: {item['snippet']}")
Purpose: Search the web and scrape content
Tools:
-
search
- Search DuckDuckGo- Params:
query
(required),num_results
(optional, default 10) - Returns: List of {title, url, snippet}
- Params:
-
scrape_url
- Extract text from URL- Params:
url
(required) - Returns: {title, content}
- Params:
When to Use:
- User asks to search for information
- User provides a URL to read
- User wants current information not in your knowledge base
Example:
User: "Search for Python async tutorials"
AI Action:
1. Check if web-search is enabled
2. Call search tool with query="Python async tutorials"
3. Present results to user with URLs
Purpose: Access Nextcloud files
Status: Coming soon
Purpose: Access Google Drive files
Status: Coming soon
Purpose: Send/receive WhatsApp messages
Status: Coming soon
Purpose: Send/receive SMS via Google Voice
Status: Coming soon
- User clicks "Enable" in MCP tab
- App updates
mcp-registry.json
:"enabled": true
- If
auto_start: true
, app starts the Python script - Status changes to
"running"
- AI can now use the server's tools
- User clicks "Disable" in MCP tab
- App stops the Python script (if running)
- App updates
mcp-registry.json
:"enabled": false
- Status changes to
"stopped"
- AI can no longer use the server's tools
- If
auto_start: true
, server starts when app launches - If
auto_start: false
, server starts only when explicitly needed
β DO use MCP servers for:
- Real-time web searches (user asks for current info)
- Fetching content from URLs (user provides link)
- Accessing user's cloud files (when implemented)
- Sending messages (when implemented)
β DON'T use MCP servers for:
- Questions you can answer from your knowledge
- Information already in the conversation context
- Every single query (use judiciously)
try:
result = await mcp_manager.execute_tool(...)
except ServerNotEnabledError:
tell_user("The web-search server is not enabled. Please enable it in Settings > MCP Servers.")
except ServerNotRunningError:
tell_user("The server is enabled but not running. Trying to start it...")
# App will attempt to restart
except ToolNotFoundError:
tell_user("That tool doesn't exist on this server.")
-
Check Before Using
- Always verify
enabled: true
before invoking - Handle cases where server is disabled
- Always verify
-
Inform the User
- Tell user when you're searching or fetching data
- "Searching the web for..."
- "Fetching content from URL..."
-
Cache Results
- Store search results in conversation context
- Avoid repeated searches for same query
-
Cite Sources
- Always include URLs when presenting web search results
- Give credit to scraped content
{
"servers": {
"server-id": {
"id": "unique-server-id",
"name": "Human-readable name",
"enabled": boolean, // Can AI use this?
"auto_start": boolean, // Start on app launch?
"status": "running|stopped|error",
"description": "What this server does",
"python_script": "path/to/script.py",
"host": "localhost",
"port": null,
"transport": "stdio",
"capabilities": ["list", "of", "capabilities"],
"tools": [
{
"name": "tool_name",
"description": "What it does",
"required_params": ["param1"],
"optional_params": ["param2"]
}
],
"requirements": ["python-package>=version"],
"platforms": ["linux", "android", "macos", "windows"],
"config_required": {
"key": "description"
}
}
}
}
The registry is live - it updates when:
- User enables/disables a server
- Server status changes
- New servers are installed
Always read the latest state before making decisions.
User: "Find me tutorials on Rust programming"
AI Process:
1. Check mcp-registry.json
2. Is web-search enabled? β Yes
3. Is status running? β Yes
4. Invoke: search(query="Rust programming tutorials", num_results=5)
5. Get results
6. Format and present to user with URLs
7. Ask if they want to read any specific page (scrape_url)
User: "Summarize this article: https://example.com/article"
AI Process:
1. Check mcp-registry.json
2. Is web-search enabled? β Yes
3. Invoke: scrape_url(url="https://example.com/article")
4. Get content
5. Read and summarize
6. Present summary to user
User: "Search for Python news"
AI Process:
1. Check mcp-registry.json
2. Is web-search enabled? β No
3. Tell user: "The web search server is not enabled. Would you like me to guide you through enabling it?"
4. If yes, explain: "Go to Settings β MCP Servers β Enable 'Web Search'"
- Check if dependencies are installed
- Check if port is already in use
- Check logs for errors
- App will attempt to restart
- If fails, status becomes "error"
- User needs to check server logs
- Check if required params are provided
- Check if values are in correct format
- Server may return error message - show to user
Remember: MCP servers extend your capabilities! Use them wisely to help users with real-time data and external integrations. π