MCP Server - JavaScript SDK
This is an unofficial JavaScript SDK for Model Context Protocol.
Usage
Import the package to your project:
npm install mcp-js-server
Create files to define the server’s prompts, resources, and tools.
Prompts
// prompts.js
export const prompts = {
hello_world: {
description: 'A simple prompt that says hello.',
arguments: [],
messages: [{
role: 'assistant',
content: {
type: 'text',
text: 'Hello, world!'
}
}]
}
};
Resources
// resources.js
export const resources = {
apiReference: {
uri: 'https://api.example.com/openapi.json',
mimeType: 'application/json'
}
};
Tools
// tools.js
export const tools = {
simple_tool: {
description: 'A simple tool',
handler: async () => new Date().toLocaleString(),
schema: {
type: 'object',
properties: {},
required: []
}
},
complex_tool: {
description: 'A complex tool',
handler: async ({ param1, param2 }) => {
return `param1: ${param1}, param2: ${param2}`;
},
schema: {
type: 'object',
properties: {
param1: { type: 'string' },
param2: { type: 'string' }
},
required: ['param1', 'param2']
}
}
};
Server
Then create a server instance with the following code:
// server.js
import { MCP } from 'mcp-server';
import { tools } from './tools.js';
import { prompts } from './prompts.js';
import { resources } from './resources.js';
const infos = {
name: 'mcp-demo-server',
version: '0.1.0'
};
const server = new MCP(infos, prompts, resources, tools);
Debugging
You can find logs of the server in your user system logs directory:
Linux: ~/.local/share/logs
macOS: ~/Library/Logs
Windows: %USERPROFILE%AppDataLocalLogs
JavaScript Server SDK
Project Details
- davlgd/mcp-js-server
- mcp-js-server
- Apache License 2.0
- Last Updated: 2/4/2025
Recomended MCP Servers
council of models for decision
Playwright Model Context Protocol Server - Tool to automate Browsers and APIs in Claude Desktop, Cline, Cursor IDE...
A integração entre o Model Context Protocol (MCP) e a computação quântica representa uma fronteira inovadora na interseção...
Let AI operate Gitee Repositories / Issues / Pull Requests for you through MCP
Free and open source manga reader for Android
Example of creating a MCP server with Nuxt & Vercel.
A Model Context Protocol (MCP) server for integrating with Notion workspaces (made before the official one 😅)
Chat with your portfolio.
特定のWeb APIに関するBaselineの状況を提供するModel Context Protocolサーバー





