JSPM

@neural-trader/mcp-protocol

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 42
  • Score
    100M100P100Q71980F
  • License MIT OR Apache-2.0

Model Context Protocol (MCP) JSON-RPC 2.0 protocol types for Neural Trader

Package Exports

  • @neural-trader/mcp-protocol
  • @neural-trader/mcp-protocol/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@neural-trader/mcp-protocol) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@neural-trader/mcp-protocol

Model Context Protocol (MCP) JSON-RPC 2.0 protocol types for Neural Trader.

Installation

npm install @neural-trader/mcp-protocol

Features

  • 🔧 Type-safe JSON-RPC 2.0 implementation
  • 📋 Standard error codes
  • ⚡ Zero dependencies (except @neural-trader/core)
  • 🎯 Full TypeScript support
  • 📦 Lightweight (~10 KB)

Usage

Creating Requests

const { createRequest } = require('@neural-trader/mcp-protocol');

// Simple request
const request = createRequest('list_strategies');

// Request with parameters
const requestWithParams = createRequest('get_strategy', { id: 'momentum-1' });

// Request with ID (for correlation)
const requestWithId = createRequest('place_order', orderParams, 'req-123');

Creating Responses

const { createSuccessResponse, createErrorResponse, ErrorCode } = require('@neural-trader/mcp-protocol');

// Success response
const success = createSuccessResponse({ status: 'ok', data: [...] }, 'req-123');

// Error response
const error = createErrorResponse(
  ErrorCode.METHOD_NOT_FOUND,
  'Method not found',
  'req-123'
);

Error Codes

const { ErrorCode } = require('@neural-trader/mcp-protocol');

console.log(ErrorCode.PARSE_ERROR);        // -32700
console.log(ErrorCode.INVALID_REQUEST);    // -32600
console.log(ErrorCode.METHOD_NOT_FOUND);   // -32601
console.log(ErrorCode.INVALID_PARAMS);     // -32602
console.log(ErrorCode.INTERNAL_ERROR);     // -32603

TypeScript

Full TypeScript support with type definitions:

import {
  JsonRpcRequest,
  JsonRpcResponse,
  JsonRpcError,
  ErrorCode,
  createRequest,
  createSuccessResponse,
  createErrorResponse
} from '@neural-trader/mcp-protocol';

const request: JsonRpcRequest = createRequest('method_name', { param: 'value' });
const response: JsonRpcResponse = createSuccessResponse({ result: 'data' }, request.id);

Specification

Implements JSON-RPC 2.0 as specified by:

License

MIT OR Apache-2.0