Copilot CLI exposes both MCP `content` and `structuredContent`
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Shell
- Star
- 11.2k
- Fork
- 1.9k
- Merge trung bình
- 14 giờ 16 phút
- Pull request đã merge (30 ngày)
- 6
Mô tả
Describe the bug
Summary
When an MCP tool result contains both content and structuredContent,
Copilot CLI appears to add both fields to the conversation context.
When structuredContent is present, the client should use it as the
structured tool result instead of exposing an equivalent or unrelated
content representation to the model.
For backward compatibility MCP tools which return structured content, should also set the unstructured content
For backwards compatibility, a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block.
see: MCP spec about structured content
Example
server.py
Here is a simple MCP server (based on the MCP Python SDK) to demonstrate the issue:
from pydantic import BaseModel
from mcp.server.mcpserver import MCPServer
class HelloOutput(BaseModel):
message: str
server = MCPServer(name="hello", version="0.1.0")
@server.tool(structured_output=True)
def hello() -> HelloOutput:
"""Return a simple JSON hello object."""
return HelloOutput(message="Hello World")
if __name__ == "__main__":
server.run("stdio")
This is what the MCP server returns for the hello tool call.
{
"_meta": null,
"content": [
{
"type": "text",
"text": "{\n \"message\": \"Hello World\"\n}",
"annotations": null,
"_meta": null
}
],
"structuredContent": {
"message": "Hello World"
},
"isError": false,
"resultType": "complete"
}
Actual Copilot CLI context
Copilot CLI exposes both representations:
{
"message": "Hello World"
}
{"message":"Hello World"}
Expected result
Only the structured result should be provided to the model:
{"message":"Hello World"}
The content field may remain available for UI rendering or backwards
compatibility, but it should not be concatenated into the model context when it
duplicates structuredContent.
Impact
The behavior unnecessarily increases context size and may cause the model to
interpret one tool result as two JSON objects.
Related issue
The reporter of issue #3258 expects the opposite behavior.
Anyway, this contradicts the intention of the MCP spec:
Tool results may contain structured or unstructured content.
For backwards compatibility, a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block.
That means:
- a MCP tool must either return structured or unstructured content (but not both)
- but they should return a serialized representation in the unstructured content block for backward compatibility (i.e. for legacy clients which don't support structured content)
Clients which support structured content must therefore silently ignore the unstructured content if there is structured content.
Affected version
GitHub Copilot CLI 1.0.80.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Sử dụng trình tái hiện MCP server.py để tạo một kết quả chứa cả content và structuredContent, sau đó theo dõi cách Copilot CLI thêm các kết quả của công cụ MCP vào ngữ cảnh cuộc trò chuyện. Xác nhận rằng chỉ structuredContent được truyền đến mô hình, trong khi content vẫn khả dụng cho việc xử lý UI hoặc khả năng tương thích, và xác minh biểu diễn JSON đơn dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- api, cli
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 52/100