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-protocolFeatures
- 🔧 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); // -32603TypeScript
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:
Related Packages
- @neural-trader/mcp - MCP server implementation
- @neural-trader/core - Core types
License
MIT OR Apache-2.0