Skip to content

feat: add MCP Apps (SEP-1865) support to platform and functions SDK#1788

Draft
simplesagar wants to merge 3 commits intomainfrom
feat/mcp-apps-support
Draft

feat: add MCP Apps (SEP-1865) support to platform and functions SDK#1788
simplesagar wants to merge 3 commits intomainfrom
feat/mcp-apps-support

Conversation

@simplesagar
Copy link
Member

@simplesagar simplesagar commented Mar 6, 2026

Summary

Adds MCP Apps (SEP-1865) support to the Gram platform and Functions SDK, enabling function authors to declare interactive UI resources that MCP-compatible hosts can render in sandboxed iframes.

Key insight: Gram's existing resource pipeline is URI-scheme and MIME-type agnostic — ui:// resources with text/html+mcp flow through the entire stack (manifest → DB → MCP endpoints → runner) with zero infrastructure changes.

Changes

  • resource() + uiResource() on the Gram class for declaring resources directly in the SDK
  • uiResource() convenience features:
    • Auto-generates ui://{name} URI when uri is omitted
    • body + styles mode wraps content in an HTML scaffold with Gram.onData() communication helper
    • Raw content mode still available for full control
  • meta on tools — optional meta?: Record<string, unknown> on ToolDefinition for linking tools to UI resources via "ui/resourceUri"
  • fromGram() resource capability — conditionally registers resources/list + resources/read MCP handlers when resources exist
  • _meta passthrough fixfromGram() now correctly passes tool meta as _meta in tools/list responses
  • handleResourceRead() — serves resource content (static or lazy/dynamic)
  • extend() merges resources from other Gram instances

What it looks like

gram.uiResource({
  name: "bar-chart",
  description: "Interactive bar chart",
  styles: `.chart { display: flex; gap: 4px; }`,
  body: `
    <div id="chart"></div>
    <script>
      Gram.onData((data) => { renderChart(data.values); });
    </script>
  `,
});

gram.tool({
  name: "generate-chart",
  meta: { "ui/resourceUri": "ui://bar-chart" },
  inputSchema: { data: z.array(z.number()) },
  async execute(ctx, input) {
    return ctx.json({ values: input.data });
  },
});

Test plan

  • pnpm test — 59 tests pass (31 source + 28 dist)
  • New tests for uiResource() auto-URI, scaffold with Gram.onData(), body-only mode
  • Existing tests for resource(), handleResourceRead(), meta flow, extend() merges
  • Manual MCP Inspector smoke test via fromGram() + stdio transport
  • mise build:server — confirm Go type change compiles

RFC: https://www.notion.so/31b726c497cc8106878cfa296200188f

🤖 Generated with Claude Code


Open with Devin

Add resource declaration capabilities to the Gram Functions SDK,
enabling function authors to declare UI resources and link tools to
them following the MCP Apps specification.

- Add resource(), uiResource(), and handleResourceRead() to Gram class
- Add meta field to ToolDefinition for tool-to-UI linking
- Update manifest() to include resources and tool meta
- Update extend() to merge resources across Gram instances
- Add resources capability to fromGram() MCP server conversion
- Align ManifestToolV0.Meta type with ManifestResourceV0.Meta (map[string]any)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@simplesagar simplesagar added the enhancement New feature or request label Mar 6, 2026
@changeset-bot
Copy link

changeset-bot bot commented Mar 6, 2026

⚠️ No Changeset found

Latest commit: a8c339d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Mar 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gram-docs-redirect Ready Ready Preview, Comment Mar 8, 2026 1:16am

Request Review

Without this, tools/list from fromGram()-created MCP servers would not
include _meta (e.g. ui/resourceUri), making it impossible for MCP Apps
hosts to discover tool-to-UI resource links.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ata() helper

uiResource() now provides genuine convenience beyond setting the MIME type:
- Auto-generates `ui://{name}` URI when `uri` is omitted
- Accepts `body` + `styles` to wrap in HTML scaffold with Gram.onData() helper
- Falls back to raw `content` mode for full control

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@simplesagar simplesagar marked this pull request as ready for review March 8, 2026 01:25
@simplesagar simplesagar requested a review from a team as a code owner March 8, 2026 01:25
@simplesagar simplesagar marked this pull request as draft March 8, 2026 01:26
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@simplesagar simplesagar removed the request for review from disintegrator March 8, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant