Skip to content

Commit 6f011b4

Browse files
committed
docs: update codeboarding documentation and generate architecture
## 📚 Documentation Update This commit contains updated documentation files fetched from the CodeBoarding service and automatically generated architecture documentation. ### 📊 Summary - Documentation files created/updated: 8 - JSON files created/updated: 9 - Documentation directory: .codeboarding/ - JSON directory: .codeboarding/ - Output format: .mdx - Repository analyzed: https://github.com/mcp-use/mcp-use - Architecture documentation: docs/development/architecture.mdx (auto-generated) The generated .mdx files have been automatically appended to the development documentation, and the architecture.mdx file has been generated from the CodeBoarding analysis files. 🤖 This commit was automatically generated by the CodeBoarding documentation update workflow.
1 parent 9ac2442 commit 6f011b4

31 files changed

Lines changed: 1683 additions & 1597 deletions
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"description": "The `mcp-use` agent subsystem is orchestrated by the `McPAgent`, which acts as the core intelligence, managing interactions with an \"Underlying LLM Agent\" for reasoning and response generation. The `McPAgent` dynamically constructs system prompts using the `SystemPromptBuilder`, which in turn leverages `Prompt Templates` for modular and reusable prompt content. All agents within the system adhere to the `BaseAgent` interface, ensuring a consistent contract for agent behavior. The \"Underlying LLM Agent\" represents the actual LLM integration, either directly through a LangChain `BaseLanguageModel` or via a `RemoteAgent` for remote execution, abstracting the specifics of the LLM provider. This architecture promotes modularity, prompt engineering best practices, and flexible LLM integration.",
3+
"components": [
4+
{
5+
"name": "McPAgent",
6+
"description": "The central orchestrator of the agent's lifecycle, responsible for LLM interaction, reasoning, dynamic prompt construction, and coordinating external tool utilization. It embodies the \"Agent Core\" pattern.",
7+
"referenced_source_code": [
8+
{
9+
"qualified_name": "mcp_use.agents.mcpagent.McPAgent",
10+
"reference_file": "/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/agents/mcpagent.py",
11+
"reference_start_line": 48,
12+
"reference_end_line": 1107
13+
}
14+
],
15+
"can_expand": true
16+
},
17+
{
18+
"name": "SystemPromptBuilder",
19+
"description": "Manages the dynamic construction of the comprehensive system prompt for the LLM, aligning with \"Prompt Engineering\" principles.",
20+
"referenced_source_code": [
21+
{
22+
"qualified_name": "mcp_use.agents.prompts.system_prompt_builder.SystemPromptBuilder",
23+
"reference_file": "/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/agents/prompts/system_prompt_builder.py",
24+
"reference_start_line": 0,
25+
"reference_end_line": 0
26+
}
27+
],
28+
"can_expand": false
29+
},
30+
{
31+
"name": "Prompt Templates",
32+
"description": "Provides reusable, predefined structures and content for various parts of the system prompt, supporting \"Prompt Engineering\" and \"Modular Design.\"",
33+
"referenced_source_code": [
34+
{
35+
"qualified_name": "mcp_use.agents.prompts.templates",
36+
"reference_file": "/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/agents/prompts/templates.py",
37+
"reference_start_line": 0,
38+
"reference_end_line": 0
39+
}
40+
],
41+
"can_expand": true
42+
},
43+
{
44+
"name": "BaseAgent",
45+
"description": "Defines the foundational contract and common interface that all agents must adhere to, promoting \"Modular Design\" and the \"Adapter Pattern.\"",
46+
"referenced_source_code": [
47+
{
48+
"qualified_name": "mcp_use.agents.base.BaseAgent",
49+
"reference_file": "/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/agents/base.py",
50+
"reference_start_line": 13,
51+
"reference_end_line": 61
52+
}
53+
],
54+
"can_expand": true
55+
},
56+
{
57+
"name": "Underlying LLM Agent",
58+
"description": "Represents the \"LLM Integration Layer,\" abstracting the specifics of the LLM provider and focusing on core function calling and response generation. This is a conceptual component that `McPAgent` interacts with, either directly via a LangChain `BaseLanguageModel` instance or through a `RemoteAgent` for remote execution.",
59+
"referenced_source_code": [
60+
{
61+
"qualified_name": "langchain_core.language_models.BaseLanguageModel",
62+
"reference_file": "/home/ubuntu/CodeBoarding/repo/mcp-use/",
63+
"reference_start_line": 0,
64+
"reference_end_line": 0
65+
},
66+
{
67+
"qualified_name": "mcp_use.agents.remote.RemoteAgent",
68+
"reference_file": "/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/agents/remote.py",
69+
"reference_start_line": 34,
70+
"reference_end_line": 327
71+
}
72+
],
73+
"can_expand": true
74+
}
75+
],
76+
"components_relations": [
77+
{
78+
"relation": "requests system prompt construction from",
79+
"src_name": "McPAgent",
80+
"dst_name": "SystemPromptBuilder"
81+
},
82+
{
83+
"relation": "initializes and configures",
84+
"src_name": "McPAgent",
85+
"dst_name": "Underlying LLM Agent"
86+
},
87+
{
88+
"relation": "implements the interface defined by",
89+
"src_name": "McPAgent",
90+
"dst_name": "BaseAgent"
91+
},
92+
{
93+
"relation": "directs to execute LLM operations",
94+
"src_name": "McPAgent",
95+
"dst_name": "Underlying LLM Agent"
96+
},
97+
{
98+
"relation": "provides structured system messages to",
99+
"src_name": "SystemPromptBuilder",
100+
"dst_name": "McPAgent"
101+
},
102+
{
103+
"relation": "utilizes for constructing prompt content",
104+
"src_name": "SystemPromptBuilder",
105+
"dst_name": "Prompt Templates"
106+
},
107+
{
108+
"relation": "supplies predefined prompt structures and content to",
109+
"src_name": "Prompt Templates",
110+
"dst_name": "SystemPromptBuilder"
111+
},
112+
{
113+
"relation": "defines the contract for",
114+
"src_name": "BaseAgent",
115+
"dst_name": "McPAgent"
116+
}
117+
]
118+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Agent Core Orchestration
2+
```mermaid
3+
graph LR
4+
McPAgent["McPAgent"]
5+
SystemPromptBuilder["SystemPromptBuilder"]
6+
Prompt_Templates["Prompt Templates"]
7+
BaseAgent["BaseAgent"]
8+
Underlying_LLM_Agent["Underlying LLM Agent"]
9+
McPAgent -- "requests system prompt construction from" --> SystemPromptBuilder
10+
McPAgent -- "initializes and configures" --> Underlying_LLM_Agent
11+
McPAgent -- "implements the interface defined by" --> BaseAgent
12+
McPAgent -- "directs to execute LLM operations" --> Underlying_LLM_Agent
13+
SystemPromptBuilder -- "provides structured system messages to" --> McPAgent
14+
SystemPromptBuilder -- "utilizes for constructing prompt content" --> Prompt_Templates
15+
Prompt_Templates -- "supplies predefined prompt structures and content to" --> SystemPromptBuilder
16+
BaseAgent -- "defines the contract for" --> McPAgent
17+
```
18+
19+
### Details
20+
21+
The `mcp-use` agent subsystem is orchestrated by the `McPAgent`, which acts as the core intelligence, managing interactions with an "Underlying LLM Agent" for reasoning and response generation. The `McPAgent` dynamically constructs system prompts using the `SystemPromptBuilder`, which in turn leverages `Prompt Templates` for modular and reusable prompt content. All agents within the system adhere to the `BaseAgent` interface, ensuring a consistent contract for agent behavior. The "Underlying LLM Agent" represents the actual LLM integration, either directly through a LangChain `BaseLanguageModel` or via a `RemoteAgent` for remote execution, abstracting the specifics of the LLM provider. This architecture promotes modularity, prompt engineering best practices, and flexible LLM integration.
22+
23+
### McPAgent
24+
The central orchestrator of the agent's lifecycle, responsible for LLM interaction, reasoning, dynamic prompt construction, and coordinating external tool utilization. It embodies the "Agent Core" pattern.
25+
26+
27+
**Related Classes/Methods**:
28+
29+
- <a href="https://github.com/mcp-use/mcp-use/blob/main/mcp_use/agents/mcpagent.py#L48-L1107" target="_blank" rel="noopener noreferrer">QName:`mcp_use.agents.mcpagent.McPAgent` FileRef: `/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/agents/mcpagent.py`, Lines:(48:1107)</a>
30+
31+
32+
### SystemPromptBuilder
33+
Manages the dynamic construction of the comprehensive system prompt for the LLM, aligning with "Prompt Engineering" principles.
34+
35+
36+
**Related Classes/Methods**:
37+
38+
- <a href="https://github.com/mcp-use/mcp-use/blob/main/mcp_use/agents/prompts/system_prompt_builder.py" target="_blank" rel="noopener noreferrer">QName:`mcp_use.agents.prompts.system_prompt_builder.SystemPromptBuilder` FileRef: `/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/agents/prompts/system_prompt_builder.py`</a>
39+
40+
41+
### Prompt Templates
42+
Provides reusable, predefined structures and content for various parts of the system prompt, supporting "Prompt Engineering" and "Modular Design."
43+
44+
45+
**Related Classes/Methods**:
46+
47+
- <a href="https://github.com/mcp-use/mcp-use/blob/main/mcp_use/agents/prompts/templates.py" target="_blank" rel="noopener noreferrer">QName:`mcp_use.agents.prompts.templates` FileRef: `/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/agents/prompts/templates.py`</a>
48+
49+
50+
### BaseAgent
51+
Defines the foundational contract and common interface that all agents must adhere to, promoting "Modular Design" and the "Adapter Pattern."
52+
53+
54+
**Related Classes/Methods**:
55+
56+
- <a href="https://github.com/mcp-use/mcp-use/blob/main/mcp_use/agents/base.py#L13-L61" target="_blank" rel="noopener noreferrer">QName:`mcp_use.agents.base.BaseAgent` FileRef: `/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/agents/base.py`, Lines:(13:61)</a>
57+
58+
59+
### Underlying LLM Agent
60+
Represents the "LLM Integration Layer," abstracting the specifics of the LLM provider and focusing on core function calling and response generation. This is a conceptual component that `McPAgent` interacts with, either directly via a LangChain `BaseLanguageModel` instance or through a `RemoteAgent` for remote execution.
61+
62+
63+
**Related Classes/Methods**:
64+
65+
- <a href="https://github.com/mcp-use/mcp-use/blob/main/" target="_blank" rel="noopener noreferrer">QName:`langchain_core.language_models.BaseLanguageModel` FileRef: `/home/ubuntu/CodeBoarding/repo/mcp-use/`</a>
66+
- <a href="https://github.com/mcp-use/mcp-use/blob/main/mcp_use/agents/remote.py#L34-L327" target="_blank" rel="noopener noreferrer">QName:`mcp_use.agents.remote.RemoteAgent` FileRef: `/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/agents/remote.py`, Lines:(34:327)</a>

.codeboarding/Agent_Orchestration_Core.json

Lines changed: 0 additions & 43 deletions
This file was deleted.

.codeboarding/Agent_Orchestration_Core.mdx

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"description": "The `Asynchronous Task Management` subsystem is critical for the `mcp-use` project, an LLM Agent Framework/Library, as it provides the foundational mechanisms for agents to interact with various communication channels asynchronously. This aligns with the project's architectural bias towards extensibility and modularity, allowing different transport layers to be plugged in seamlessly.",
3+
"components": [
4+
{
5+
"name": "BaseTaskManager",
6+
"description": "Defines the abstract interface and core lifecycle management for asynchronous connections and background tasks. It provides a common structure for establishing, maintaining, and closing connections, acting as the blueprint for all specific task managers.",
7+
"referenced_source_code": [
8+
{
9+
"qualified_name": "mcp_use.task_managers.base.BaseTaskManager",
10+
"reference_file": "/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/task_managers/base.py",
11+
"reference_start_line": 1,
12+
"reference_end_line": 1
13+
}
14+
],
15+
"can_expand": true
16+
},
17+
{
18+
"name": "StdioTaskManager",
19+
"description": "Manages asynchronous tasks specifically for standard input/output (stdio) streams, enabling console-based communication for agents. This is crucial for local development, debugging, and simple interactive agent sessions.",
20+
"referenced_source_code": [
21+
{
22+
"qualified_name": "mcp_use.task_managers.stdio.StdioTaskManager",
23+
"reference_file": "/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/task_managers/stdio.py",
24+
"reference_start_line": 1,
25+
"reference_end_line": 1
26+
}
27+
],
28+
"can_expand": false
29+
},
30+
{
31+
"name": "WebSocketTaskManager",
32+
"description": "Manages asynchronous tasks for WebSocket connections, facilitating persistent, full-duplex communication channels for agents. This is vital for real-time, interactive agent-to-agent or agent-to-client communication.",
33+
"referenced_source_code": [
34+
{
35+
"qualified_name": "mcp_use.task_managers.websocket.WebSocketTaskManager",
36+
"reference_file": "/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/task_managers/websocket.py",
37+
"reference_start_line": 1,
38+
"reference_end_line": 1
39+
}
40+
],
41+
"can_expand": true
42+
},
43+
{
44+
"name": "SseTaskManager",
45+
"description": "Manages asynchronous tasks for Server-Sent Events (SSE), enabling agents to receive continuous event streams from a server. This is useful for one-way, server-initiated updates or notifications to agents.",
46+
"referenced_source_code": [
47+
{
48+
"qualified_name": "mcp_use.task_managers.sse.SseTaskManager",
49+
"reference_file": "/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/task_managers/sse.py",
50+
"reference_start_line": 1,
51+
"reference_end_line": 1
52+
}
53+
],
54+
"can_expand": true
55+
},
56+
{
57+
"name": "StreamableHttpTaskManager",
58+
"description": "Manages asynchronous tasks for streamable HTTP connections, allowing for long-lived HTTP requests that continuously stream data, potentially for agent communication or data ingestion. This supports scenarios requiring continuous data flow over HTTP without full-duplex WebSockets.",
59+
"referenced_source_code": [
60+
{
61+
"qualified_name": "mcp_use.task_managers.streamable_http.StreamableHttpTaskManager",
62+
"reference_file": "/home/ubuntu/CodeBoarding/repo/mcp-use/mcp_use/task_managers/streamable_http.py",
63+
"reference_start_line": 1,
64+
"reference_end_line": 1
65+
}
66+
],
67+
"can_expand": true
68+
}
69+
],
70+
"components_relations": [
71+
{
72+
"relation": "defines contract for",
73+
"src_name": "BaseTaskManager",
74+
"dst_name": "StdioTaskManager"
75+
},
76+
{
77+
"relation": "defines contract for",
78+
"src_name": "BaseTaskManager",
79+
"dst_name": "WebSocketTaskManager"
80+
},
81+
{
82+
"relation": "defines contract for",
83+
"src_name": "BaseTaskManager",
84+
"dst_name": "SseTaskManager"
85+
},
86+
{
87+
"relation": "defines contract for",
88+
"src_name": "BaseTaskManager",
89+
"dst_name": "StreamableHttpTaskManager"
90+
},
91+
{
92+
"relation": "inherits from",
93+
"src_name": "StdioTaskManager",
94+
"dst_name": "BaseTaskManager"
95+
},
96+
{
97+
"relation": "inherits from",
98+
"src_name": "WebSocketTaskManager",
99+
"dst_name": "BaseTaskManager"
100+
},
101+
{
102+
"relation": "inherits from",
103+
"src_name": "SseTaskManager",
104+
"dst_name": "BaseTaskManager"
105+
},
106+
{
107+
"relation": "inherits from",
108+
"src_name": "StreamableHttpTaskManager",
109+
"dst_name": "BaseTaskManager"
110+
}
111+
]
112+
}

0 commit comments

Comments
 (0)