Conversation
There was a problem hiding this comment.
Pull request overview
Extends the MCP adapter to support additional MCP (2025-06-18) features—structured content, output schemas, and new result content types—so MCP integrations don’t silently drop important data.
Changes:
- Add
SelectableItem.output_schemawithto_dict()/from_dict()support. - Extend
mcp_tool_to_selectable()to map MCPoutputSchema. - Extend
mcp_result_to_envelope()to handleaudio,resource_link, top-levelstructuredContent, and per-partannotations, plus add tests/docs/changelog entries.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_adapters.py |
Adds coverage for new MCP content types, annotations, and output_schema round-tripping. |
src/contextweaver/types.py |
Introduces SelectableItem.output_schema and serialisation support. |
src/contextweaver/adapters/mcp.py |
Implements MCP outputSchema mapping and new result parsing behaviors (audio/resource_link/structuredContent/annotations). |
docs/integration_mcp.md |
Documents new MCP behaviors and supported content types. |
CHANGELOG.md |
Records the newly supported MCP features. |
You can also share your feedback on Copilot code review. Take the survey.
|
Good point — the image and audio blocks were near-identical, and the module was at 324 lines (above the 300-line target). Extracted a |
|
Great catch — the Fixed by using Added an explicit assertion in the test to lock this in. Committed in 21f5314. |
|
Thanks for the thorough review! All three items have been addressed:
All 63 adapter tests pass, lint and type checks are clean. Ready for re-review when you get a chance! |
…w content types Handle all MCP spec (2025-06-18) content types in the MCP adapter: - Add output_schema field to SelectableItem; map outputSchema from MCP tool definitions in mcp_tool_to_selectable() - Handle audio content type (base64-decoded binary artifact) - Handle resource_link content type (URI reference as ArtifactRef) - Handle top-level structuredContent (stored as application/json artifact with fact extraction from top-level keys) - Collect per-part annotations (audience, priority) into provenance["content_annotations"] - Update MCP integration docs with new content type reference - Add 16 tests covering all new content types and round-trip Closes #102
21f5314 to
04b1a86
Compare
What changed
Extends the MCP adapter to handle all content types from the MCP spec (revision 2025-06-18). Closes #102.
SelectableItem(types.py)output_schema: dict[str, Any] | None = Nonefield withto_dict()/from_dict()supportmcp_tool_to_selectable()(adapters/mcp.py)outputSchemafrom MCP tool definition toSelectableItem.output_schemamcp_result_to_envelope()(adapters/mcp.py)audiocontent type: base64-decoded, stored as binary artifact (same pattern asimage)resource_linkcontent type: URI stored asArtifactRefwithsize_bytes=0structuredContent(top-level): serialized asapplication/jsonartifact, top-level keys extracted as factsannotations:audienceandprioritycollected intoprovenance["content_annotations"]Documentation (
docs/integration_mcp.md)Tests (
tests/test_adapters.py)outputSchemamapping,audio(valid + invalid base64),resource_link(with/without name),structuredContent(with content + standalone), content-part annotations (present + absent), mixed content types coexistence,SelectableItem.output_schemaround-tripWhy
Issue #102 identified that the MCP adapter silently dropped
structuredContent,audio,resource_link,outputSchema, and content-part annotations — all features added in the MCP 2025-06-18 revision.How verified
Tradeoffs / risks
resource_linkstores the URI as raw bytes in binaries for caller resolution — no automatic fetchstructuredContentfact extraction is limited to top-level keys with short string representations (<200 chars)Scope notes
SelectableItemtype, tests, docs, and changelogAGENTS.md,CLAUDE.md,.github/copilot-instructions.md) reviewed — no updates needed (they don't list individual field names)