agentscope-ai / agentscope-ai/ReMe

bug: MCP tool responses lose structured metadata — only human-readable text is returned

未关闭
#376 4 条评论 0 个 reaction 已指派 2 人 已被 @ployts 认领 在 GitHub 查看
主要语言
Python
星标
3.4k
派生
298
平均合并
19 小时 52 分钟
30 天内合并 PR
55

描述

## Description

When calling ReMe tools via MCP protocol (SSE/stdio/streamable-http), the structured
metadata in `Response.metadata` is silently discarded. Clients receive only the
human-readable `answer` string, making it impossible to programmatically access file
lists, search results, graph edges, etc.

## Affected Tools

| Tool | What client receives | Lost metadata |
|---------------|--------------------------------------|----------------------------------------------|
| `list` | `"Listed 4 file(s) under user-001/"` | `items: string[]`, `count: int` |
| `search` | Human-readable search text | `results`, `link_expansion`, `counts` |
| `daily_list` | Human-readable note list | `notes`, `count`, `date` |
| `traverse` | Graph traversal text | `edges`, `count` |
| `node_search` | Node list text | `hits`, `counts` |
| `proactive` | Read result summary | `topics`, `content`, `skipped` |

All MCP clients (not limited to any specific client) are affected.

## Root Cause

In `reme/components/service/mcp_service.py`, the `execute_tool` closure inside
`MCPService.add_job()` returns only `response.answer`:

```python
async def execute_tool(**kwargs):
response = await job(**kwargs)
return response.answer # ← metadata discarded here
```
The HTTP Service correctly returns the full Response JSON (with answer + metadata), but the MCP Service does not.

## Expected Behavior
MCP clients should be able to access structured metadata from tool responses, consistent with what the HTTP Service provides.

## Environment
ReMe version: 0.4.x
Transport: SSE (also affects stdio and streamable-http)
Python: 3.12

---

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。