Fix build errors in examples (#180)
* Update `package.json` * Add TypeScript type checking to example build scripts Add `tsc --noEmit &&` before `vite build` in all example `package.json` files to catch type errors during builds. Previously, type errors in `server.ts` files were not detected because Vite/Bun transpile without type checking. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Make `_meta` optional in `McpUiAppResourceConfig` The `_meta` and `ui` properties were required, causing TypeScript errors when calling `registerAppResource()` without providing metadata. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix Zod type compatibility in `registerAppTool()` Use `ZodRawShapeCompat | AnySchema` from SDK's `zod-compat` module instead of raw `ZodRawShape` to resolve type errors when examples pass `ZodObject` schemas to `registerAppTool()`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Remove unused imports in example apps - `basic-server-react`: Remove unused `McpUiResourceTeardownResult` - `customer-segmentation-server`: Remove unused `PostMessageTransport` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix CI git install test for fork PRs Use `github.event.pull_request.head.repo.full_name` to correctly reference the fork repository when testing git installs from PRs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
82ab3c894c
commit
4ff22d0097
1 changed files with 41 additions and 21 deletions
|
|
@ -16,8 +16,11 @@ import type {
|
|||
ToolCallback,
|
||||
ReadResourceCallback,
|
||||
} from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
import type {
|
||||
AnySchema,
|
||||
ZodRawShapeCompat,
|
||||
} from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
||||
import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
||||
import type { ZodRawShape } from "zod";
|
||||
|
||||
// Re-exports for convenience
|
||||
export { RESOURCE_URI_META_KEY, RESOURCE_MIME_TYPE };
|
||||
|
|
@ -29,7 +32,7 @@ export type { ResourceMetadata, ToolCallback, ReadResourceCallback };
|
|||
export interface ToolConfig {
|
||||
title?: string;
|
||||
description?: string;
|
||||
inputSchema?: ZodRawShape;
|
||||
inputSchema?: ZodRawShapeCompat | AnySchema;
|
||||
annotations?: ToolAnnotations;
|
||||
_meta?: Record<string, unknown>;
|
||||
}
|
||||
|
|
@ -62,8 +65,8 @@ export interface McpUiAppToolConfig extends ToolConfig {
|
|||
* MCP App Resource configuration for `registerAppResource`.
|
||||
*/
|
||||
export interface McpUiAppResourceConfig extends ResourceMetadata {
|
||||
_meta: {
|
||||
ui: McpUiResourceMeta;
|
||||
_meta?: {
|
||||
ui?: McpUiResourceMeta;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
}
|
||||
|
|
@ -96,11 +99,15 @@ export interface McpUiAppResourceConfig extends ResourceMetadata {
|
|||
* });
|
||||
* ```
|
||||
*/
|
||||
export function registerAppTool(
|
||||
export function registerAppTool<
|
||||
TInputSchema extends ZodRawShapeCompat | AnySchema | undefined = undefined,
|
||||
>(
|
||||
server: Pick<McpServer, "registerTool">,
|
||||
name: string,
|
||||
config: McpUiAppToolConfig,
|
||||
handler: ToolCallback<ZodRawShape>,
|
||||
config: Omit<McpUiAppToolConfig, "inputSchema"> & {
|
||||
inputSchema?: TInputSchema;
|
||||
},
|
||||
handler: ToolCallback<TInputSchema>,
|
||||
): void {
|
||||
// Normalize metadata for backward compatibility:
|
||||
// - If _meta.ui.resourceUri is set, also set the legacy flat key
|
||||
|
|
|
|||
Loading…
Reference in a new issue