Skip to content

Support MCP resource links for media/artifact outputs instead of text-only JSON in all three SDKs #123

Done

Description

@tercel

Summary

All three SDKs return tool results as a single MCP text content block. There is no ImageContent, AudioContent, EmbeddedResource, or resource_link path, and no declared-artifact convention. A media-producing module can only return a path string or a multi-megabyte base64 string inside text.

This is consistent with the current spec (apcore-mcp SRS FR-EXEC-002: "SHALL return ... JSON string in the MCP text content"), so this issue is a spec change proposal, not an implementation divergence.

Cross-language result

SDK Version / HEAD Result shape Other content types Evidence
Python 0.23.4 / 2887706 [{"type":"text","text":...}] None server/router.py:337, 415, 557
TypeScript 0.23.4 / 8506903 TextContentDict[] only None src/types.ts:177-180, src/server/router.ts:63, 544-759, factory.ts:720-726
Rust 0.23.4 / a991ed1 Vec<TextContent> Internal trace → _meta.trace only src/server/types.rs:54-93, factory.rs:846-857

Both TypeScript and Rust already expose outputSchema + structuredContent; that covers structured JSON, not file handoff. resources exist only for documentation (docs://{module_id}) and system metadata, not for call artifacts.

Impact

  • AI clients receive media as text, not as files, so they cannot preview, save, or pass artifacts to another tool.
  • Large binary results inflate model context and may be truncated by the client.
  • Media pipelines must invent a path convention, and the receiving client has no portable way to fetch the file.
  • For a local pipeline this is the difference between "the agent can inspect the render" and "the agent gets a filename".

Proposed fix

Add a declared-artifact convention to the adapter spec, implemented in all three SDKs:

  1. A module output field can opt into artifact handling, e.g. "x-mcp-artifact": true or a descriptor-level artifacts: ["final_path"].
  2. The adapter emits:
    • a text summary (unchanged), plus
    • a resource_link (or EmbeddedResource below a small configurable threshold) pointing at the file, with mimeType and name.
  3. Never embed large files as base64; define a size threshold and a documented fallback to a path string.
  4. Keep structuredContent for the structured part of the result.

Add a conformance fixture (artifact_content.json) with a driver contract so all three SDKs emit the same shape.

Acceptance criteria

  • A module returning { "summary": "...", "artifact": "/path/final.mp4" } yields a text summary plus a resource link, with no base64 payload.
  • The behavior is identical in Python, TypeScript, and Rust.
  • Clients that do not support resource links continue to receive the text summary.
  • The SRS/feature docs describe the convention and the size threshold.

Related

  • Python issue: aiperceivable/apcore-mcp-python#10
  • Spec: apcore-mcp/docs/srs-apcore-mcp.md FR-EXEC-002; docs/prd-apcore-mcp.md OQ-1

Activity

  1. added
    enhancement
    on Nov 23, 2026
  2. tercel commented on Nov 29, 2026

    @tercel
    ContributorAuthor

    The beta media-link pilot landed in #130 across Python, TypeScript, and Rust. The adapter accepts an opaque ID in an x-mcp-artifact output field, retains text and structured data, and serves authorized bytes via resources/read with expiry and size bounds. This closes the resource-link pilot scope. The original local-path and inline-content alternatives are outside that delivered contract. Paired verification: https://github.com/aiperceivable/apcore-surfaces/actions/runs/46205760166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions