You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -20,7 +20,7 @@ Additional features incorporating AGNTCY's identity and observability components
20
20
21
21
### ⚡️ Connecting an MCP client to an MCP server over an abstract transport (SLIM | NATS | MQTT)
22
22
23
-
A benefit of decoupling protocols from transports is that you can easily create agents that communicate over non http, point-to-point transports such as NATS or Agntcy's SLIM. Below is an example of how to create two A2A agents that communicate over SLIM's PubSub gateway.
23
+
A benefit of decoupling protocols from transports is that you can easily create agents that communicate over non http, point-to-point transports such as NATS or Agntcy's SLIM. Below is an example of how to create an MCP client and server that communicate over SLIM's gateway server.
24
24
25
25
We will use `uv` for package management and virtual environments. If you don't have it installed, you can install it via:
26
26
@@ -31,8 +31,8 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
31
31
Create a new project directory:
32
32
33
33
```bash
34
-
uv init a2a-pubsub
35
-
cda2a-pubsub
34
+
uv init agntcy-mcp
35
+
cdagntcy-mcp
36
36
```
37
37
38
38
Install the Agntcy Application SDK and Langgraph:
@@ -44,142 +44,52 @@ uv add agntcy-app-sdk
44
44
Next we will create a simple weather agent that responds to weather queries. Create a file named `weather_agent.py` and implement the A2A agent and add a message bridge to a SLIM transport:
45
45
46
46
```python
47
-
from a2a.server.agent_execution import AgentExecutor, RequestContext
48
-
from a2a.server.events import EventQueue
49
-
from a2a.utils import new_agent_text_message
50
-
from a2a.types import (
51
-
AgentCapabilities,
52
-
AgentCard,
53
-
AgentSkill,
54
-
)
55
-
from a2a.server.apps import A2AStarletteApplication
56
-
from a2a.server.request_handlers import DefaultRequestHandler
57
-
from a2a.server.tasks import InMemoryTaskStore
58
47
from agntcy_app_sdk.factory import AgntcyFactory
48
+
from mcp.server.fastmcp import FastMCP
59
49
60
-
"""
61
-
Create the AgentSkill and AgentCard for a simple weather report agent.
62
-
"""
63
-
64
-
skill = AgentSkill(
65
-
id="weather_report",
66
-
name="Returns weather report",
67
-
description="Provides a simple weather report",
68
-
tags=["weather", "report"],
69
-
examples=["What's the weather like?", "Give me a weather report"],
70
-
)
71
-
72
-
agent_card = AgentCard(
73
-
name="Weather Agent",
74
-
description="An agent that provides weather reports",
75
-
url="",
76
-
version="1.0.0",
77
-
defaultInputModes=["text"],
78
-
defaultOutputModes=["text"],
79
-
capabilities=AgentCapabilities(streaming=True),
80
-
skills=[skill],
81
-
supportsAuthenticatedExtendedCard=False,
82
-
)
83
-
84
-
"""
85
-
Create the actual agent logic and executor.
86
-
"""
87
-
88
-
classWeatherAgent:
89
-
"""A simple agent that returns a weather report."""
Next we will create a simple client agent that queries the weather agent. Create a file named `weather_client.py` and implement the A2A client with a SLIM transport:
137
68
138
69
```python
139
-
from a2a.types import (
140
-
SendMessageRequest,
141
-
MessageSendParams,
142
-
Message,
143
-
Part,
144
-
TextPart,
145
-
Role,
146
-
)
147
-
148
70
from agntcy_app_sdk.factory import AgntcyFactory
149
-
from agntcy_app_sdk.factory import ProtocolTypes
150
-
from agntcy_app_sdk.protocols.a2a.protocol import A2AProtocol
151
-
from weather_agent import agent_card
152
71
153
72
factory = AgntcyFactory()
154
73
transport = factory.create_transport("SLIM", endpoint="http://localhost:46357")
155
-
156
-
asyncdefmain():
157
-
# create an app-sdk factory to create the transport and bridge
0 commit comments