Skip to main content
Glama
johnhenry

MCP Declarative Server

by johnhenry

MCP 宣言型サーバー

モデルコンテキストプロトコル (MCP) サーバーを宣言的に作成するためのユーティリティ モジュール。

インストール

npm install mcp-client-router

Related MCP server: YA_MCPServer Template

使用法

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

// Create a server declaratively
const server = new DeclarativeMCPServer({
  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リファレンス

DeclarativeMCPServer

new DeclarativeMCPServer(options);

オプション

  • name (文字列): サーバーの名前

  • version (文字列): サーバーのバージョン

  • tools (配列):ツール定義の配列

  • prompts (配列): プロンプト定義の配列

  • resources (配列):リソース定義の配列

ツール定義フォーマット

[
  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
];

ライセンス

ISC

A
license - permissive license
Not graded
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    A command-line tool for creating and running Model Context Protocol servers that expose resources, tools, and prompts to LLM clients.
    84
    1
    AGPL 3.0
  • F
    license
    Not graded
    quality
    D
    maintenance
    A boilerplate template for developing Model Context Protocol (MCP) servers, providing a structured framework for defining tools, resources, and prompts.
  • A
    license
    Not graded
    quality
    D
    maintenance
    A toy MCP server for exploring Model Context Protocol capabilities, including resources, tools, and prompts.
    Apache 2.0

View all related MCP servers

Related MCP Connectors

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…

  • MCP server for generating rough-draft project plans from natural-language prompts.

  • A Model Context Protocol server for Wix AI tools

View all MCP Connectors

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/johnhenry/mcp-declarative-server'

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