mcp.agents.documentation_agent¶

MCP Documentation Agent for processing and setting up MCP servers.

This module provides a specialized agent that combines document processing capabilities with MCP knowledge to help users understand, configure, and implement MCP servers. It processes documentation from various sources and generates actionable setup instructions.

The agent uses document processing capabilities to:
  1. Load MCP server documentation from stored resources (992+ servers)

  2. Fetch additional documentation from GitHub repositories

  3. Generate setup instructions for agents

  4. Provide implementation guidance with code examples

  5. Extract capabilities and configuration requirements

  6. Create ready-to-use MCPServerConfig instances

Classes:

MCPDocumentationAgent: Document agent specialized for MCP documentation

Functions:

create_for_mcp_setup: Factory for setup-focused documentation agent create_for_mcp_research: Factory for research-focused documentation agent

Example

Processing MCP server documentation:

from haive.mcp.agents import MCPDocumentationAgent

from haive import core from haive import agents

# Create documentation agent doc_agent = MCPDocumentationAgent.create_for_mcp_setup() await doc_agent.setup()

# Process filesystem server documentation result = await doc_agent.process_mcp_server(

“modelcontextprotocol/server-filesystem”, fetch_latest=True

)

# Get setup instructions print(”n”.join(result[“setup_instructions”]))

# Get generated config config = result[“mcp_config”] print(f”Server: {config.name}”) print(f”Command: {config.command} {’ ‘.join(config.args)}”)

# Find servers by capability search_results = await doc_agent.find_servers_by_capability(

“database”, limit=5

)

for server in search_results:

print(f”Found: {server[‘server_name’]}”)

Note

The agent has access to pre-processed documentation for 992+ MCP servers stored in the agent_resources directory.

Attributes¶

Classes¶

MCPDocumentationAgent

Agent specialized for processing MCP server documentation and generating setup instructions.

Module Contents¶

class mcp.agents.documentation_agent.MCPDocumentationAgent(**kwargs)¶

Bases: haive.mcp.mixins.mcp_mixin.MCPMixin, haive.agents.document.agent.DocumentAgent

Agent specialized for processing MCP server documentation and generating setup instructions.

MCPDocumentationAgent extends DocumentAgent with specialized capabilities for processing Model Context Protocol server documentation. It can extract setup instructions, generate configurations, and provide implementation guidance from various documentation sources.

The agent combines document processing capabilities with MCP knowledge to:
  • Load and process MCP server documentation from stored resources

  • Extract setup instructions from README files and documentation

  • Generate MCPServerConfig instances from documentation

  • Provide implementation guidance with code examples

  • Search for servers by capability or category

  • Create combined configurations for multi-server setups

doc_loader¶

MCPDocumentationLoader instance for accessing stored docs

resources_path¶

Path to MCP server resources directory

Inherits from:

MCPMixin: Provides MCP client capabilities DocumentAgent: Provides document processing capabilities

Example

Basic documentation processing:

# Create documentation agent
doc_agent = MCPDocumentationAgent.create_for_mcp_setup(
    engine=engine
)
await doc_agent.setup()

# Process filesystem server docs
result = await doc_agent.process_mcp_server(
    "modelcontextprotocol/server-filesystem"
)

# Extract components
setup_steps = result["setup_instructions"]
mcp_config = result["mcp_config"]
capabilities = result["capabilities"]

print(f"Server: {mcp_config.name}")
print(f"Capabilities: {', '.join(capabilities)}")
print("\nSetup Instructions:")
for step in setup_steps:
    print(f"  {step}")

Advanced multi-server setup:

# Generate implementation guide for multiple servers
guide = await doc_agent.generate_implementation_guide(
    server_names=[
        "modelcontextprotocol/server-filesystem",
        "modelcontextprotocol/server-github",
        "modelcontextprotocol/server-postgres"
    ],
    target_agent_type="research"
)

# Get combined configuration
combined_config = guide["combined_config"]

# Get implementation code
implementation = guide["implementation_code"]
print(implementation)
classmethod create_for_mcp_research(**kwargs) MCPDocumentationAgent¶

Create an agent for researching MCP capabilities.

Factory method that creates an agent optimized for comprehensive research across multiple MCP server documentations. Uses parallel processing and embeddings for efficient search.

Parameters:

**kwargs – Additional arguments including: - engine: Required AugLLMConfig - resources_path: Optional path to resources

Returns:

Agent configured for research with:
  • Parallel processing for multiple documents

  • Recursive chunking with overlap

  • Embedding generation enabled

  • Maximum worker threads for speed

Return type:

MCPDocumentationAgent

Example

Researching MCP capabilities:

agent = MCPDocumentationAgent.create_for_mcp_research(
    engine=engine
)

# Find all database-related servers
db_servers = await agent.find_servers_by_capability(
    "database",
    limit=10
)

# Research each server's capabilities
for server in db_servers:
    print(f"\n{server['server_name']}:")
    print(f"  Capabilities: {server['capabilities']}")
    print(f"  Setup: {len(server['setup_instructions'])} steps")
classmethod create_for_mcp_setup(**kwargs) MCPDocumentationAgent¶

Create an agent optimized for MCP setup documentation.

Factory method that creates an agent specifically configured for extracting setup instructions and configuration from MCP server documentation. Uses semantic chunking for better context preservation.

Parameters:

**kwargs – Additional arguments including: - engine: Required AugLLMConfig - resources_path: Optional path to resources

Returns:

Agent configured for setup extraction with:
  • Semantic chunking for preserving setup steps

  • Enhanced processing for code extraction

  • Metadata extraction enabled

  • Language detection for code blocks

Return type:

MCPDocumentationAgent

Example

Creating a setup-focused agent:

agent = MCPDocumentationAgent.create_for_mcp_setup(
    engine=engine
)

# Process server setup documentation
result = await agent.process_mcp_server(
    "modelcontextprotocol/server-brave-search"
)

# Get installation commands
for cmd in result["setup_instructions"]:
    if cmd.startswith("npm") or cmd.startswith("npx"):
        print(f"Run: {cmd}")
async find_servers_by_capability(capability: str, limit: int = 10) list[dict[str, Any]]¶

Find MCP servers that provide a specific capability.

Searches through all available MCP server documentation to find servers that mention a specific capability in their description or documentation. Returns detailed setup information for each.

Parameters:
  • capability – Capability to search for (e.g., “database”, “search”, “filesystem”, “api”, “git”, “calendar”)

  • limit – Maximum number of results to return (default: 10)

Returns:

List of server information dicts, each containing:
  • server_name: Full server identifier

  • setup_instructions: Installation and setup commands

  • mcp_config: Ready-to-use MCPServerConfig

  • capabilities: List of all server capabilities

Return type:

List[Dict[str, Any]]

Example

Finding database servers:

async generate_implementation_guide(server_names: list[str], target_agent_type: str = 'general') dict[str, Any]¶

Generate a complete implementation guide for using MCP servers.

Creates a comprehensive guide including configurations, setup instructions, and implementation code for integrating multiple MCP servers into an agent. Processes each server documentation and combines them into a unified guide.

Parameters:
  • server_names – List of full MCP server names to include (e.g., [“modelcontextprotocol/server-filesystem”, “modelcontextprotocol/server-github”])

  • target_agent_type – Type of agent to generate code for. Options: - “general”: Basic MCPAgent implementation - “research”: Research-focused agent setup - “task”: Task execution agent setup - “collaborative”: Multi-agent collaborative setup

Returns:

Complete implementation guide containing:
  • agent_type: The specified target agent type

  • servers: Dict mapping server names to their processed info

  • combined_config: MCPConfig with all servers configured

  • implementation_code: Ready-to-use Python code

  • usage_examples: List of example code snippets

Return type:

Dict[str, Any]

Example

Generating a research agent guide:

async process_mcp_server(server_name: str, fetch_latest: bool = True) dict[str, Any]¶

Process documentation for a specific MCP server.

Loads and processes documentation for a single MCP server, extracting setup instructions, configuration, and capabilities. Can fetch latest documentation from GitHub or use cached versions.

Parameters:
  • server_name – Full name of the MCP server including organization (e.g., “modelcontextprotocol/server-filesystem”)

  • fetch_latest – Whether to fetch latest docs from GitHub repository (default: True). Set to False for faster cached access.

Returns:

Processed server information containing:
  • server_name: The input server name

  • setup_instructions: List of setup command strings

  • mcp_config: MCPServerConfig instance ready to use

  • documentation: Full processed documentation dict

  • capabilities: List of capability strings

Return type:

Dict[str, Any]

Example

Processing with latest documentation:

doc_loader: haive.mcp.documentation.doc_loader.MCPDocumentationLoader = None¶
resources_path: pathlib.Path | None = None¶
mcp.agents.documentation_agent.logger¶