Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ We welcome contributions to the MCP Apps SDK! This document outlines the process
1. Create a new branch for your changes
2. Make your changes
3. Run `npm run prettier` to ensure code style compliance
4. Run `npm test` to verify all tests pass
5. Submit a pull request
4. If running prettier fails, run `npm run prettier:fix` to fix
5. Run `npm test` to verify all tests pass
6. Submit a pull request

## Pull Request Guidelines

Expand Down
10 changes: 0 additions & 10 deletions src/app-bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -844,16 +844,6 @@ describe("getToolUiResourceUri", () => {
});
});

describe("deprecated flat format (_meta['ui/resourceUri'])", () => {
it("extracts resourceUri from deprecated format", () => {
const tool = {
name: "test-tool",
_meta: { "ui/resourceUri": "ui://server/app.html" },
};
expect(getToolUiResourceUri(tool)).toBe("ui://server/app.html");
});
});

describe("format precedence", () => {
it("prefers new nested format over deprecated format", () => {
const tool = {
Expand Down
16 changes: 3 additions & 13 deletions src/app-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import {
} from "./types";
export * from "./types";
export { RESOURCE_URI_META_KEY, RESOURCE_MIME_TYPE } from "./app";
import { RESOURCE_URI_META_KEY } from "./app";
export { PostMessageTransport } from "./message-transport";

/**
Expand All @@ -100,12 +99,6 @@ export { PostMessageTransport } from "./message-transport";
* const uri = getToolUiResourceUri({
* _meta: { ui: { resourceUri: "ui://server/app.html" } }
* });
*
* // Deprecated flat format (still supported)
* const uri = getToolUiResourceUri({
* _meta: { "ui/resourceUri": "ui://server/app.html" }
* });
* ```
*/
export function getToolUiResourceUri(tool: {
_meta?: Record<string, unknown>;
Expand All @@ -114,15 +107,12 @@ export function getToolUiResourceUri(tool: {
const uiMeta = tool._meta?.ui as { resourceUri?: unknown } | undefined;
let uri: unknown = uiMeta?.resourceUri;

// Fall back to deprecated flat format: _meta["ui/resourceUri"]
if (uri === undefined) {
uri = tool._meta?.[RESOURCE_URI_META_KEY];
}

if (typeof uri === "string" && uri.startsWith("ui://")) {
return uri;
} else if (uri !== undefined) {
throw new Error(`Invalid UI resource URI: ${JSON.stringify(uri)}`);
throw new Error(
`Invalid UI resource URI: ${JSON.stringify(uri)}. URI must be a string and start with "ui://"`,
);
}
return undefined;
}
Expand Down
Loading