Skip to content

Commit 85d19fd

Browse files
committed
adapted docs
1 parent f2e4cef commit 85d19fd

File tree

2 files changed

+170
-69
lines changed

2 files changed

+170
-69
lines changed

README.md

Lines changed: 71 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,73 @@ asyncio.run(main())
138138
139139
---
140140

141+
## 🤝 Cross-Agent Communication
142+
143+
DeepMCPAgent v0.5 introduces **Cross-Agent Communication** — agents that can _talk to each other_ without extra servers, message queues, or orchestration layers.
144+
145+
You can now attach one agent as a **peer** inside another, turning it into a callable tool.
146+
Each peer appears automatically as `ask_agent_<name>` or can be reached via `broadcast_to_agents` for parallel reasoning across multiple agents.
147+
148+
This means your agents can **delegate**, **collaborate**, and **critique** each other — all through the same MCP tool interface.
149+
It’s lightweight, model-agnostic, and fully transparent: every peer call is traced like any other tool invocation.
150+
151+
---
152+
153+
### 💻 Example
154+
155+
```python
156+
import asyncio
157+
from deepmcpagent import HTTPServerSpec, build_deep_agent
158+
from deepmcpagent.cross_agent import CrossAgent
159+
160+
async def main():
161+
# 1️⃣ Build a "research" peer agent
162+
research_graph, _ = await build_deep_agent(
163+
servers={"web": HTTPServerSpec(url="http://127.0.0.1:8000/mcp")},
164+
model="openai:gpt-4o-mini",
165+
instructions="You are a focused research assistant that finds and summarizes sources.",
166+
)
167+
168+
# 2️⃣ Build the main agent and attach the peer as a tool
169+
main_graph, _ = await build_deep_agent(
170+
servers={"math": HTTPServerSpec(url="http://127.0.0.1:9000/mcp")},
171+
model="openai:gpt-4.1",
172+
instructions="You are a lead analyst. Use peers when you need research or summarization.",
173+
cross_agents={
174+
"researcher": CrossAgent(agent=research_graph, description="A web research peer.")
175+
},
176+
trace_tools=True, # see all tool calls + peer responses in console
177+
)
178+
179+
# 3️⃣ Ask a question — the main agent can now call the researcher
180+
result = await main_graph.ainvoke({
181+
"messages": [{"role": "user", "content": "Find recent research on AI ethics and summarize it."}]
182+
})
183+
184+
print(result)
185+
186+
asyncio.run(main())
187+
```
188+
189+
🧩 **Result:**
190+
Your main agent automatically calls `ask_agent_researcher(...)` when it decides delegation makes sense, and the peer agent returns its best final answer — all transparently handled by the MCP layer.
191+
192+
---
193+
194+
### 💡 Use Cases
195+
196+
- Researcher → Writer → Editor pipelines
197+
- Safety or reviewer peers that audit outputs
198+
- Retrieval or reasoning specialists
199+
- Multi-model ensembles combining small and large LLMs
200+
201+
No new infrastructure. No complex orchestration.
202+
Just **agents helping agents**, powered entirely by MCP over HTTP/SSE.
203+
204+
> 🧠 One framework, many minds — **DeepMCPAgent** turns individual LLMs into a cooperative system.
205+
206+
---
207+
141208
## 🖥️ CLI (no Python required)
142209

143210
```bash
@@ -160,25 +227,6 @@ deepmcpagent run \
160227
161228
---
162229
163-
## 🧩 Architecture (at a glance)
164-
165-
```
166-
┌────────────────┐ list_tools / call_tool ┌─────────────────────────┐
167-
│ LangChain/LLM │ ──────────────────────────────────▶ │ FastMCP Client (HTTP/SSE)│
168-
│ (your model) │ └───────────┬──────────────┘
169-
└──────┬─────────┘ tools (LC BaseTool) │
170-
│ │
171-
▼ ▼
172-
LangGraph Agent One or many MCP servers (remote APIs)
173-
(or DeepAgents) e.g., math, github, search, ...
174-
```
175-
176-
- `HTTPServerSpec(...)` → **FastMCP client** (single client, multiple servers)
177-
- **Tool discovery** → JSON-Schema → Pydantic → LangChain `BaseTool`
178-
- **Agent loop** → DeepAgents (if installed) or LangGraph ReAct fallback
179-
180-
---
181-
182230
## Full Architecture & Agent Flow
183231
184232
### 1) High-level Architecture (modules & data flow)
@@ -381,56 +429,6 @@ classDiagram
381429

382430
---
383431

384-
### 5) Deployment / Integration View (clusters & boundaries)
385-
386-
```mermaid
387-
flowchart TD
388-
subgraph App["Your App / Service"]
389-
UI["CLI / API / Notebook"]
390-
Code["deepmcpagent (Python pkg)\n- config.py\n- clients.py\n- tools.py\n- agent.py\n- prompt.py"]
391-
UI --> Code
392-
end
393-
394-
subgraph Cloud["LLM Provider(s)"]
395-
P1["OpenAI / Anthropic / Groq / Ollama..."]
396-
end
397-
398-
subgraph Net["Network"]
399-
direction LR
400-
FMCP["FastMCP Client\n(HTTP/SSE)"]
401-
FMCP ---|mcpServers| Code
402-
end
403-
404-
subgraph Servers["MCP Servers"]
405-
direction LR
406-
A["Service A (HTTP)\n/path: /mcp"]
407-
B["Service B (SSE)\n/path: /mcp"]
408-
C["Service C (HTTP)\n/path: /mcp"]
409-
end
410-
411-
Code -->|init_chat_model or model instance| P1
412-
Code --> FMCP
413-
FMCP --> A
414-
FMCP --> B
415-
FMCP --> C
416-
```
417-
418-
---
419-
420-
### 6) Error Handling & Observability (tool errors & retries)
421-
422-
```mermaid
423-
flowchart TD
424-
Start([Tool Call]) --> Try{"client.call_tool(name,args)"}
425-
Try -- ok --> Parse["Extract data/text/content/result"]
426-
Parse --> Return[Return ToolMessage to Agent]
427-
Try -- raises --> Err["Tool/Transport Error"]
428-
Err --> Wrap["ToolMessage(status=error, content=trace)"]
429-
Wrap --> Agent["Agent observes error\nand may retry / alternate tool"]
430-
```
431-
432-
---
433-
434432
> These diagrams reflect the current implementation:
435433
>
436434
> - **Model is required** (string provider-id or LangChain model instance).
@@ -515,3 +513,7 @@ Apache-2.0 — see [`LICENSE`](/LICENSE).
515513
- The [**MCP** community](https://modelcontextprotocol.io/) for a clean protocol.
516514
- [**LangChain**](https://www.langchain.com/) and [**LangGraph**](https://www.langchain.com/langgraph) for powerful agent runtimes.
517515
- [**FastMCP**](https://gofastmcp.com/getting-started/welcome) for solid client & server implementations.
516+
517+
```
518+
519+
```

docs/changelog.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,103 @@
11
# Changelog
22

3+
## 0.5.0 — 2025-10-18
4+
5+
### Added
6+
7+
- Cross-Agent Communication (in-process) with `cross_agent.py`.
8+
- `CrossAgent`, `make_cross_agent_tools`, `ask_agent_<name>`, and `broadcast_to_agents`.
9+
- `build_deep_agent(..., cross_agents=...)` to attach peers as tools.
10+
- Example `examples/use_cross_agent.py`.
11+
- Cross-Agent documentation section.
12+
13+
### Changed
14+
15+
- Pydantic v2 config via `model_config = ConfigDict(extra="forbid")`.
16+
17+
### Fixed
18+
19+
- Clearer trace output for cross-agent tool calls.
20+
- Better errors for unknown peers in `broadcast_to_agents`.
21+
- Implemented sync `_run` on tools to satisfy `BaseTool`.
22+
23+
---
24+
25+
## 0.4.1 — 2025-10-17
26+
27+
### Added
28+
29+
- No new features.
30+
31+
### Changed
32+
33+
- Updated runtime compatibility for environments without `deepagents` installed (graceful fallback to ReAct agent).
34+
- Minor code cleanup and improved defensive checks in the agent builder.
35+
36+
### Fixed
37+
38+
- Fixed `TypeError` when falling back to `create_react_agent()` with `langgraph>=0.6`.
39+
- Agent builder now dynamically detects supported parameters and omits deprecated ones for smooth operation across LangGraph versions.
40+
- Improved `_after()` trace hook to skip `None` values when `trace_tools=True`, correctly displaying tool results.
41+
42+
---
43+
44+
## 0.4.0
45+
46+
### Added
47+
48+
- CLI now supports pretty console output, `--trace/--no-trace`, and `--raw` modes.
49+
- HTTP server specs fully supported with block string syntax (`--http "name=... url=..."`).
50+
- Tool tracing hooks (`on_before`, `on_after`, `on_error`) integrated into the agent layer.
51+
- Richer agent streaming output: shows invoked tools, arguments, and results.
52+
- Added `__version__` export via package metadata.
53+
- Basic PyTests
54+
55+
### Changed
56+
57+
- Updated runtime dependencies:
58+
- `langgraph` and `langgraph-prebuilt` pinned to `>=0.6,<0.7`.
59+
- `langchain` bumped to `>=0.3.27`.
60+
- `fastmcp` bumped to `>=2.12.2`.
61+
- CLI and agent examples polished for consistency and usability.
62+
- Development extras modernized (latest `ruff`, `mypy`, `pytest`, etc.).
63+
64+
### Fixed
65+
66+
- Multiple Ruff issues (imports, `Optional``X | None`, try/except cleanups).
67+
- Validation errors in CLI argument parsing.
68+
- Tool discovery now handles `None` or empty results gracefully.
69+
- Safer error handling in `_FastMCPTool` when tool callbacks raise.
70+
- CI workflow stabilized for PyPI publishing with setuptools-scm dynamic versioning.
71+
72+
---
73+
374
## 0.3.0
75+
76+
### Added
77+
78+
- Improved JSON Schema → Pydantic mapping:
79+
- Carries through defaults and descriptions via `Field`.
80+
- Generates per-tool arg models (`Args_<tool>`).
81+
- Sanitizes model names for Pydantic compatibility.
82+
- CLI improvements:
83+
- Added `--version` flag.
84+
- Simplified option parsing.
85+
- Updated documentation.
86+
- PyPI Trusted Publishing workflow (publish on tag).
87+
- CI improvements: Ruff formatting, mypy fixes, skip deep extra on Python 3.10.
88+
89+
### Fixed
90+
91+
- Type errors in CLI, agent, tools, and clients.
92+
- CLI annotation options adjusted to satisfy Ruff rules.
93+
94+
### Changed
95+
96+
- Project license clarified to Apache-2.0.
97+
- Project metadata aligned with license notice.
98+
99+
---
100+
101+
## 0.1.0
102+
4103
- Initial FastMCP client edition.

0 commit comments

Comments
 (0)