mcp-use
Version:
Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.
78 lines • 3.14 kB
TypeScript
/**
* Server Helper Utilities
*
* General utility functions for the MCP server.
*/
import { type Hono as HonoType } from "hono";
import { cors } from "hono/cors";
/**
* Get default CORS configuration for MCP server
*
* @returns CORS options object for Hono cors middleware
*/
export declare function getDefaultCorsOptions(): Parameters<typeof cors>[0];
/**
* Create and configure a new Hono app instance with default middleware
*
* Sets up CORS and request logging middleware for the MCP server.
*
* @param requestLogger - Request logging middleware function
* @returns Configured Hono app instance
*/
export declare function createHonoApp(requestLogger: any): HonoType;
/**
* Get the server base URL with fallback to host:port if not configured
*
* @param serverBaseUrl - Explicitly configured base URL
* @param serverHost - Server hostname
* @param serverPort - Server port
* @returns The complete base URL for the server
*/
export declare function getServerBaseUrl(serverBaseUrl: string | undefined, serverHost: string, serverPort: number | undefined): string;
/**
* Get additional CSP URLs from environment variable
* Supports comma-separated list or single URL
*
* @returns Array of URLs to add to CSP resource_domains
*/
export declare function getCSPUrls(): string[];
/**
* Wait for transport.handleRequest to complete and response to be written
*
* Wraps the transport.handleRequest call in a Promise that only resolves when
* expressRes.end() is called, ensuring all async operations complete before
* we attempt to read the response.
*
* @param transport - The transport instance
* @param expressReq - Express-like request object
* @param expressRes - Express-like response object
* @param body - Optional request body
* @returns Promise that resolves when the request is complete
*/
export declare function waitForRequestComplete(transport: any, expressReq: any, expressRes: any, body?: any): Promise<void>;
/**
* Log registered tools, prompts, and resources to console
*
* @param registeredTools - Array of registered tool names
* @param registeredPrompts - Array of registered prompt names
* @param registeredResources - Array of registered resource names
*/
export declare function logRegisteredItems(registeredTools: string[], registeredPrompts: string[], registeredResources: string[]): void;
/**
* Parse parameter values from a URI based on a template
*
* Extracts parameter values from an actual URI by matching it against a URI template.
* The template contains placeholders like {param} which are extracted as key-value pairs.
*
* @param template - URI template with placeholders (e.g., "user://{userId}/posts/{postId}")
* @param uri - Actual URI to parse (e.g., "user://123/posts/456")
* @returns Object mapping parameter names to their values
*
* @example
* ```typescript
* const params = parseTemplateUri("user://{userId}/posts/{postId}", "user://123/posts/456")
* // Returns: { userId: "123", postId: "456" }
* ```
*/
export declare function parseTemplateUri(template: string, uri: string): Record<string, string>;
//# sourceMappingURL=server-helpers.d.ts.map