Skip to main content
Glama
davlgd

MCP JavaScript Server

by davlgd

MCP 서버 - JavaScript SDK

이는 Model Context Protocol을 위한 비공식 JavaScript SDK입니다.

용법

프로젝트에 패키지를 가져옵니다.

지엑스피1

서버의 프롬프트, 리소스, 도구를 정의하는 파일을 만듭니다.

프롬프트

// 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.js
export const resources = {
    apiReference: {
        uri: 'https://api.example.com/openapi.json',
        mimeType: 'application/json'
    }
};

도구

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

디버깅

사용자 시스템 로그 디렉토리에서 서버 로그를 찾을 수 있습니다.

Linux:   ~/.local/share/logs
macOS:   ~/Library/Logs
Windows: %USERPROFILE%\AppData\Local\Logs
-
security - not tested
A
license - permissive license
-
quality - not tested

Resources

Looking for Admin?

Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.

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/davlgd/mcp-js-server'

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