MCP Declarative Server
A utility module for creating Model Context Protocol (MCP) servers declaratively.
Installation
npm install mcp-client-router
Usage
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 Reference
DeclarativeMCPServer
new DeclarativeMCPServer(options);
Options
name
(string): The name of the serverversion
(string): The version of the servertools
(array): An array of tool definitionsprompts
(array): An array of prompt definitionsresources
(array): An array of resource definitions
Tool Definition Format
[
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
];
Prompt Definition Format
[
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
];
Resource Definition Format
[
uri, // string: URI of the resource
handler, // function: async function to handle the resource request
];
License
ISC
Declarative MCP Server
by johnhenry
267
Project Details
- johnhenry/mcp-declarative-server
- Last Updated: 4/28/2025
Recomended MCP Servers
MCP-Test Server
Forest Fire Visualization Server
Magic Admin Python SDK
Magic admin Python SDK makes it easy to leverage Decentralized ID tokens to protect routes and restricted resources...
Vidu Video Generation Server
MCP server for Vidu video generation API
Cal.com Calendar Integration
MCP Server
Global Notion workspace-accessible MCP server for all Notion pages within the workspace
HubSpot MCP Server by CData
This read-only MCP Server allows you to connect to HubSpot data from Claude Desktop through CData JDBC Drivers....
AWS S3 Operations Server
OpenWorkspace-o1 S3 Model Context Protocol Server.
Financial Analyzer
Luma MCP Server
BSC MCP Server
Scrapezy MCP Server