Skip to main content
Glama
Mulan Permissive Software License, Version 2
2
  • Linux
  • Apple
notificationHandlers.js1.8 kB
import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { LoggingMessageNotificationSchema, PromptListChangedNotificationSchema, ResourceListChangedNotificationSchema, ToolListChangedNotificationSchema, } from "@modelcontextprotocol/sdk/types.js"; export function setupAllNotificationHandlers(client, server, serverName) { client.setNotificationHandler(ToolListChangedNotificationSchema, (notification) => { console.log(`[${serverName}] Tool list changed...`, JSON.stringify(notification, null, 4)); server.sendToolListChanged(); client.listTools().then((tools) => { console.log("更新后的工具列表:", tools); }); }); client.setNotificationHandler(ResourceListChangedNotificationSchema, (notification) => { console.log(`[${serverName}] Resource list changed...`, JSON.stringify(notification, null, 4)); server.sendResourceListChanged(); client.listResources().then((resources) => { console.log("更新后的资源列表:", resources); }); }); client.setNotificationHandler(PromptListChangedNotificationSchema, (notification) => { console.log(`[${serverName}] Prompt list changed...`, JSON.stringify(notification, null, 4)); server.sendPromptListChanged(); client.listPrompts().then((prompts) => { console.log("更新后的提示列表:", prompts); }); }); client.setNotificationHandler(LoggingMessageNotificationSchema, (notification) => { console.log(`[${serverName}] Log message...`, JSON.stringify(notification, null, 4)); server.sendLoggingMessage(notification.params); }); } //# sourceMappingURL=notificationHandlers.js.map

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/masx200/mcp-demo-streamable-http-bridge'

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