Rocky_Mountain_Vending/.pnpm-store/v10/files/13/0efb021e49c56af685b9792883e7d1571cdb62f9cf1f6eae7aa57e744a24e1c44f63fb4fab6dbb8294aa87d59c344c5d1c93cd7d66f0e7bcc3959d1b05dd78
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

89 lines
2.3 KiB
Text

import { DEBUG_BUILD } from '../../debug-build.js';
import { debug } from '../../utils/debug-logger.js';
/**
* Message validation functions for MCP server instrumentation
*
* Provides JSON-RPC 2.0 message type validation and MCP server instance validation.
*/
/**
* Validates if a message is a JSON-RPC request
* @param message - Message to validate
* @returns True if message is a JSON-RPC request
*/
function isJsonRpcRequest(message) {
return (
typeof message === 'object' &&
message !== null &&
'jsonrpc' in message &&
(message ).jsonrpc === '2.0' &&
'method' in message &&
'id' in message
);
}
/**
* Validates if a message is a JSON-RPC notification
* @param message - Message to validate
* @returns True if message is a JSON-RPC notification
*/
function isJsonRpcNotification(message) {
return (
typeof message === 'object' &&
message !== null &&
'jsonrpc' in message &&
(message ).jsonrpc === '2.0' &&
'method' in message &&
!('id' in message)
);
}
/**
* Validates if a message is a JSON-RPC response
* @param message - Message to validate
* @returns True if message is a JSON-RPC response
*/
function isJsonRpcResponse(message) {
return (
typeof message === 'object' &&
message !== null &&
'jsonrpc' in message &&
(message ).jsonrpc === '2.0' &&
'id' in message &&
('result' in message || 'error' in message)
);
}
/**
* Validates MCP server instance with type checking
* @param instance - Object to validate as MCP server instance
* @returns True if instance has required MCP server methods
*/
function validateMcpServerInstance(instance) {
if (
typeof instance === 'object' &&
instance !== null &&
'resource' in instance &&
'tool' in instance &&
'prompt' in instance &&
'connect' in instance
) {
return true;
}
DEBUG_BUILD && debug.warn('Did not patch MCP server. Interface is incompatible.');
return false;
}
/**
* Check if the item is a valid content item
* @param item - The item to check
* @returns True if the item is a valid content item, false otherwise
*/
function isValidContentItem(item) {
return item != null && typeof item === 'object';
}
export { isJsonRpcNotification, isJsonRpcRequest, isJsonRpcResponse, isValidContentItem, validateMcpServerInstance };
//# sourceMappingURL=validation.js.map