Skip to main content
Glama
davlgd

MCP JavaScript Server

by davlgd

Servidor MCP - SDK de JavaScript

Este es un SDK de JavaScript no oficial para el Protocolo de Contexto de Modelo .

Uso

Importa el paquete a tu proyecto:

npm install mcp-js-server

Crea archivos para definir las indicaciones, los recursos y las herramientas del servidor.

Indicaciones

// prompts.js
export const prompts = {
    hello_world: {
        description: 'A simple prompt that says hello.',
        arguments: [],
        messages: [{
            role: 'assistant',
            content: {
                type: 'text',
                text: 'Hello, world!'
            }
        }]
    }
};

Recursos

// resources.js
export const resources = {
    apiReference: {
        uri: 'https://api.example.com/openapi.json',
        mimeType: 'application/json'
    }
};

Herramientas

// 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']
        }
    }
};

Servidor

Luego crea una instancia de servidor con el siguiente código:

// 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);

Depuración

Puede encontrar registros del servidor en el directorio de registros del sistema de su usuario:

Linux:   ~/.local/share/logs
macOS:   ~/Library/Logs
Windows: %USERPROFILE%\AppData\Local\Logs

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A Python implementation of the Model Context Protocol that allows applications to provide standardized context for LLMs, enabling creation of servers that expose data and functionality to LLM applications through resources, tools, and prompts.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A toolkit for building Model Context Protocol servers and clients that provide standardized context for LLMs, allowing applications to expose resources, tools, and prompts through stdio or Streamable HTTP transports.
    76,226,448 npm
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    A lightweight SDK for building Model Context Protocol (MCP) servers with zero-config setup, automatic TypeScript type inference, and Zod runtime validation.
    11 npm
    3
    MIT