a2a-agent-mcpserver-generator 0.1.1__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: a2a-agent-mcpserver-generator
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Add your description here
5
5
  Author-email: vincent-pli <justdoit.pli@gmail.com>
6
6
  Requires-Python: >=3.13
@@ -24,6 +24,11 @@ English | [简体中文](./README-zh.md)
24
24
  - Complete Project Setup: Generates all necessary files to run an MCP server
25
25
  - Easy Configuration: Simple environment-based configuration for the generated server
26
26
 
27
+ ## Prerequisites
28
+
29
+ - Python 3.13+
30
+ - `uv` (optional, but recommended) or `pip`
31
+
27
32
  ## Environment Setup 🔧
28
33
  Firstly, you need to start up a a2a agent:
29
34
  https://github.com/google/a2a-python/tree/main/examples
@@ -35,7 +40,7 @@ uv run a2a-agent-mcpserver-generator --agent http://0.0.0.0:10000
35
40
  ## Installation 📦
36
41
 
37
42
  ```bash
38
- pip install a2a-agent-mcpserver-generator
43
+ uv pip install a2a-agent-mcpserver-generator
39
44
  ```
40
45
 
41
46
  ## Usage 🚀
@@ -0,0 +1,61 @@
1
+ # A2A Agent 到 MCP 服务器 🤖
2
+ 这是一个命令行工具,可以从一行命令的 a2a 代理生成 Model Context Protocol(MCP)服务器代码。这个工具可以帮助你快速创建一个 MCP 服务器,用来作为 LLMs(大语言模型)和 a2a 代理之间的桥梁。
3
+ English | [简体中文](./README-zh.md)
4
+
5
+ ## 特性 ✨
6
+ - 自动工具生成:将 a2a 代理的每个 `技能` 转换为一个 MCP 工具
7
+ - 传输选项:仅支持 stdio,如果要使用 sse 可以借助 mcp-proxy
8
+ - 完整的项目设置:生成运行 MCP 服务器所需的所有文件
9
+ - 简易配置:生成的服务器采用基于环境的简单配置
10
+
11
+ ## 前置条件
12
+ - Python 3.13+
13
+ - `uv` (可选,但建议) 或 `pip`
14
+
15
+ ## 环境设置 🔧
16
+ 首先,你需要启动一个 a2a 代理:
17
+ https://github.com/google/a2a-python/tree/main/examples
18
+ ```
19
+ uv run a2a-agent-mcpserver-generator --agent http://0.0.0.0:10000
20
+ ```
21
+ ## 安装 📦
22
+ ```bash
23
+ uv pip install a2a-agent-mcpserver-generator
24
+ ```
25
+ ## 使用 🚀
26
+ ```
27
+ uv run a2a-agent-mcpserver-generator --help
28
+ 使用方法:a2a-agent-mcpserver-generator [选项]
29
+ 选项:
30
+ --agent TEXT
31
+ --output TEXT
32
+ --name TEXT
33
+ --history BOOLEAN
34
+ --use_push_notifications BOOLEAN
35
+ --push_notification_receiver TEXT
36
+ --help 显示此消息并退出。
37
+ ```
38
+ ## E2E 示例
39
+ 建议使用 [mcpclihost](https://github.com/vincent-pli/mcp-cli-host) 作为 MCP 主机进行尝试。
40
+ 这个工具(`mcpclihost`)可以同时支持 Azure Openai 和 deepseek
41
+ 你可以像这样添加生成的 MCP 服务器配置:
42
+ ```
43
+ {
44
+ "mcpServers": {
45
+ "a2a-mcp": {
46
+ "command": "uv",
47
+ "args": [
48
+ "--project",
49
+ "/Users/lipeng/workspaces/github.com/vincent-pli/a2a-agent-mcpserver-generator/a2a-mcp-server",
50
+ "run",
51
+ "a2a-agent-mcpserver"
52
+ ]
53
+ }
54
+ }
55
+ }
56
+ ```
57
+ 向 `~/.mcp.json`(`mcpclihost` 的默认 MCP 服务器配置路径)添加上述内容,然后试试看。
58
+
59
+ ## 许可协议
60
+
61
+ 这个项目采用 Apache 2.0 许可协议 - 详情请见[LICENSE](LICENSE)文件。
@@ -11,6 +11,11 @@ English | [简体中文](./README-zh.md)
11
11
  - Complete Project Setup: Generates all necessary files to run an MCP server
12
12
  - Easy Configuration: Simple environment-based configuration for the generated server
13
13
 
14
+ ## Prerequisites
15
+
16
+ - Python 3.13+
17
+ - `uv` (optional, but recommended) or `pip`
18
+
14
19
  ## Environment Setup 🔧
15
20
  Firstly, you need to start up a a2a agent:
16
21
  https://github.com/google/a2a-python/tree/main/examples
@@ -22,7 +27,7 @@ uv run a2a-agent-mcpserver-generator --agent http://0.0.0.0:10000
22
27
  ## Installation 📦
23
28
 
24
29
  ```bash
25
- pip install a2a-agent-mcpserver-generator
30
+ uv pip install a2a-agent-mcpserver-generator
26
31
  ```
27
32
 
28
33
  ## Usage 🚀
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "a2a-agent-mcpserver-generator"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "Add your description here"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -45,9 +45,14 @@ async def main(
45
45
  log.info(f'- Server Name: {name}')
46
46
 
47
47
  # Load agent.json
48
- async with httpx.AsyncClient() as httpx_client:
49
- card_resolver = A2ACardResolver(httpx_client=httpx_client, base_url=agent)
50
- card: AgentCard = await card_resolver.get_agent_card()
48
+ try:
49
+ async with httpx.AsyncClient() as httpx_client:
50
+ card_resolver = A2ACardResolver(httpx_client=httpx_client, base_url=agent)
51
+ card: AgentCard = await card_resolver.get_agent_card()
52
+ except Exception as e:
53
+ log.error(f"failed to get agent card from address: {agent}")
54
+ log.error(e)
55
+ return
51
56
 
52
57
  # Parse agent.json
53
58
  card_parsed: CardParsed = parse_card(card)
@@ -145,9 +145,10 @@ async def handle_call_tool(name: str, arguments: dict) -> list[types.TextContent
145
145
 
146
146
  if isinstance(chunk.root.result, TaskStatusUpdateEvent):
147
147
  task_status = chunk.root.result
148
- ctx.session.send_log_message(
148
+ notification_msg = ''.join(part.root.text for part in task_status.status.message.parts) if task_status.status.message else ""
149
+ await ctx.session.send_log_message(
149
150
  level="info",
150
- data=f"Task: {{task_id}} is {{task_status.status.state}} at {{task_status.status.timestamp}} with message: {{task_status.status.message}}",
151
+ data=f"Task: {{task_id}} is '{{task_status.status.state}}' with message: {{notification_msg}}",
151
152
  logger="notification_stream",
152
153
  related_request_id=ctx.request_id,
153
154
  )
@@ -188,10 +189,10 @@ async def handle_call_tool(name: str, arguments: dict) -> list[types.TextContent
188
189
  )]
189
190
 
190
191
  task = get_response.root.result
191
-
192
- ctx.session.send_log_message(
192
+ notification_msg = ''.join(part.root.text for part in task_status.status.message.parts) if task_status.status.message else ""
193
+ await ctx.session.send_log_message(
193
194
  level="info",
194
- data=f"Task: {{task_id}} is {{task.status.state}} at {{task.status.timestamp}} with message: {{task.status.message}}",
195
+ data=f"Task: {{task_id}} is '{{task_status.status.state}}' with message: {{notification_msg}}",
195
196
  logger="notification_stream",
196
197
  related_request_id=ctx.request_id,
197
198
  )