MCP-Mirror

MCP Server - JavaScript SDK

Community MCP-Mirror
Updated

Mirror of https://github.com/davlgd/mcp-js-server

MCP Server - JavaScript SDK

This is an unofficial JavaScript SDK for Model Context Protocol.

Usage

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%\AppData\Local\Logs

MCP Server · Populars

MCP Server · New

    PraneshASP

    Foundry MCP Server

    An experimental MCP Server for foundry built for Solidity devs

    Community PraneshASP
    karakeep-app

    Karakeep MCP Server

    A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

    Community karakeep-app
    karakeep-app

    karakeep

    A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

    Community karakeep-app
    prisma

    Prisma

    Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB

    Community prisma
    iannuttall

    Flux UI MCP Server

    MCP Server

    Community iannuttall