Skip to main content
Glama
soriat

MCP Elicitations Demo Server

by soriat
tool-get-resource-reference.ts1.36 kB
import { z } from "zod"; import { zodToJsonSchema } from "zod-to-json-schema"; import { generateAllResources } from "../lib/resources.js"; const GetResourceReferenceSchema = z.object({ resourceId: z .number() .min(1) .max(100) .describe("ID of the resource to reference (1-100)"), }); export const getResourceReferenceTool = { name: "getResourceReference", description: "Returns a resource reference that can be used by MCP clients", inputSchema: zodToJsonSchema(GetResourceReferenceSchema), handler: async (args: any) => { const validatedArgs = GetResourceReferenceSchema.parse(args); const resourceId = validatedArgs.resourceId; const ALL_RESOURCES = generateAllResources(); const resourceIndex = resourceId - 1; if (resourceIndex < 0 || resourceIndex >= ALL_RESOURCES.length) { throw new Error(`Resource with ID ${resourceId} does not exist`); } const resource = ALL_RESOURCES[resourceIndex]; return { content: [ { type: "text" as const, text: `Returning resource reference for Resource ${resourceId}:`, }, { type: "resource" as const, resource: resource, }, { type: "text" as const, text: `You can access this resource using the URI: ${resource.uri}`, }, ], }; }, };

Implementation Reference

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/soriat/soria-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server