@timesheet/mcp
Version:
Model Context Protocol server for Timesheet API
132 lines • 4.69 kB
TypeScript
/**
* MCP Apps Helper Functions
* Utilities for formatting tool responses with MCP Apps metadata (SEP-1865)
*
* Uses the standardized MCP Apps schema:
* - URI scheme: ui://timesheet/<component>.html
* - MIME type: text/html;profile=mcp-app
* - Metadata: _meta.ui.* (with OpenAI compat keys retained)
*/
import { RESOURCE_MIME_TYPE } from '@modelcontextprotocol/ext-apps/server';
export { RESOURCE_MIME_TYPE };
/**
* Get the resource URI for a component
*/
export declare function getComponentResourceUri(componentName: string): string;
export declare function getComponentBaseUrl(): string;
/**
* Add MCP Apps component metadata to a tool response
*/
export declare function addComponentMetadata(response: any, componentName: string, widgetDescription: string): any;
/**
* Format timer response with component
*/
export declare function formatTimerResponse(timerData: any, profile?: any, settings?: any): any;
/**
* Format project list response with component
*/
export declare function formatProjectListResponse(projects: any[], totalCount: number, queryParams?: Record<string, any>, profile?: any, settings?: any): any;
/**
* Format project card response with component
*/
export declare function formatProjectCardResponse(project: any): any;
/**
* Format task list response with component
*/
export declare function formatTaskListResponse(tasks: any[], queryParams?: any, profile?: any, settings?: any): any;
/**
* Format task card response with component
*/
export declare function formatTaskCardResponse(task: any): any;
/**
* Format statistics response with component
*/
export declare function formatStatisticsResponse(stats: any, profile?: any, settings?: any): any;
/**
* Format export template list response with component
*/
export declare function formatExportTemplateListResponse(templates: any[], totalCount: number): any;
/**
* Get component metadata for tool definition (not response)
*/
export declare function getComponentMetadataForTool(componentName: string): {
ui: {
resourceUri: string;
visibility: string[];
};
};
/**
* Get static widget description for resource metadata
* These are generic descriptions that apply to the widget regardless of data
*/
export declare function getStaticWidgetDescription(componentName: string): string;
/**
* Get the MCP server's public URL (for OAuth resource identifier)
*/
export declare function getMcpServerUrl(): string;
/**
* Get the Timesheet API base URL
*/
export declare function getApiBaseUrl(): string;
/**
* OAuth 2.1 authorization metadata for MCP Initialize response
* This tells ChatGPT how to authenticate with this MCP server
*/
export declare function getOAuthMetadata(): {
method: string;
resource: string;
authorization_servers: string[];
authorization_endpoint: string;
token_endpoint: string;
registration_endpoint: string;
metadata_uri: string;
protected_resource_metadata_uri: string;
};
/**
* Protected Resource Metadata (RFC 9728)
* This describes this MCP server as an OAuth 2.1 protected resource
* ChatGPT fetches this to discover how to authenticate
*/
export declare function getProtectedResourceMetadata(): {
resource: string;
authorization_servers: string[];
scopes_supported: string[];
bearer_methods_supported: string[];
resource_documentation: string;
};
/**
* Authorization Server Metadata (RFC 8414)
* This describes the OAuth 2.1 authorization server capabilities
* ChatGPT fetches this to discover endpoints and supported features
*/
export declare function getAuthorizationServerMetadata(): {
issuer: string;
authorization_endpoint: string;
token_endpoint: string;
registration_endpoint: string;
code_challenge_methods_supported: string[];
grant_types_supported: string[];
response_types_supported: string[];
token_endpoint_auth_methods_supported: string[];
scopes_supported: string[];
service_documentation: string;
};
/**
* Generate WWW-Authenticate header value for 401 responses
* Compliant with RFC 6750 (Bearer Token Usage)
*/
export declare function getWWWAuthenticateHeader(error?: string, errorDescription?: string): string;
/**
* Extract Bearer token from Authorization header
* Returns null if no valid Bearer token found
*/
export declare function extractBearerToken(authorizationHeader?: string): string | null;
/**
* Check if a token looks like a valid JWT (basic format check)
*/
export declare function isJwtToken(token: string): boolean;
/**
* Check if a token looks like a Timesheet API key
*/
export declare function isApiKeyToken(token: string): boolean;
//# sourceMappingURL=mcp-app-helpers.d.ts.map