Token导航 LogoToken导航TokenDH.com
MCP Declarative Server logo
AI代理未说明官方级别未说明来源级核验

MCP Declarative Server

MCP Server

用于通过声明式配置创建MCP协议服务器的工具模块,支持工具、提示模板和资源的快速定义与部署。

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
JavaScript资源管理AI代理

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

johnhenry

提供方

johnhenry

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

MCP声明服务器

用于以声明方式创建模型上下文协议(MCP)服务器的实用模块。

安装

npm install mcp-client-router

用法

import { MCPDeclarativeServer } from "mcp-client-router/declarative-server";

// Create a server declaratively
const server = new MCPDeclarativeServer({
  name: "my-server",
  version: "1.0.0",

  // Define tools as arrays of arguments
  tools: [
    [
      "greeting",
      { message: "string" },
      async ({ message }) => ({
        content: [{ type: "text", text: `Hello, ${message}!` }],
      }),
    ],
    [
      "farewell",
      { name: "string" },
      async ({ name }) => ({
        content: [{ type: "text", text: `Goodbye, ${name}!` }],
      }),
    ],
  ],

  // Define prompts
  prompts: [
    [
      "welcome",
      { name: "string", formality: { type: "string", default: "CASUAL" } },
      async ({ name, formality }) => {
        const text =
          formality === "FORMAL"
            ? `Dear ${name}, welcome to our service.`
            : `Hi ${name}! Welcome aboard!`;

        return {
          messages: [{ role: "assistant", content: { text } }],
        };
      },
      "A welcome prompt template",
    ],
  ],

  // Define resources
  resources: [
    [
      "docs/readme",
      async () => ({
        contents: [
          {
            uri: "docs/readme",
            text: "This is the documentation readme file.",
          },
        ],
      }),
    ],
  ],
});

// Connect to a transport
await server.connect(transport);

api参考

MCPDeclarativeServer

new MCPDeclarativeServer(options);

选项

  • name (string):服务器的名称
  • version (string):服务器的版本
  • tools (array):工具定义数组
  • prompts (array):提示定义数组
  • resources (array):资源定义数组

工具定义格式

[
  name, // string: name of the tool
  paramSchema, // object: parameter schema
  handler, // function: async function to handle the tool call
  description, // string (optional): description of the tool
];

提示定义格式

[
  name, // string: name of the prompt
  paramSchema, // object: parameter schema
  handler, // function: async function to handle the prompt
  description, // string (optional): description of the prompt
];

资源定义格式

[
  uri, // string: URI of the resource
  handler, // function: async function to handle the resource request
];

许可证

国际协调委员会

目录标签

目录标签

JavaScript资源管理AI代理协议服务器本地部署声明式配置工具定义提示模板

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP