mcp-wordpress 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +568 -0
- package/bin/mcp-wordpress.js +12 -0
- package/bin/setup.js +302 -0
- package/bin/status.js +359 -0
- package/dist/client/WordPressClient.d.ts +81 -0
- package/dist/client/WordPressClient.d.ts.map +1 -0
- package/dist/client/WordPressClient.js +354 -0
- package/dist/client/WordPressClient.js.map +1 -0
- package/dist/client/api.d.ts +140 -0
- package/dist/client/api.d.ts.map +1 -0
- package/dist/client/api.js +727 -0
- package/dist/client/api.js.map +1 -0
- package/dist/client/auth.d.ts +121 -0
- package/dist/client/auth.d.ts.map +1 -0
- package/dist/client/auth.js +430 -0
- package/dist/client/auth.js.map +1 -0
- package/dist/client/managers/AuthenticationManager.d.ts +39 -0
- package/dist/client/managers/AuthenticationManager.d.ts.map +1 -0
- package/dist/client/managers/AuthenticationManager.js +159 -0
- package/dist/client/managers/AuthenticationManager.js.map +1 -0
- package/dist/client/managers/BaseManager.d.ts +22 -0
- package/dist/client/managers/BaseManager.d.ts.map +1 -0
- package/dist/client/managers/BaseManager.js +47 -0
- package/dist/client/managers/BaseManager.js.map +1 -0
- package/dist/client/managers/RequestManager.d.ts +45 -0
- package/dist/client/managers/RequestManager.d.ts.map +1 -0
- package/dist/client/managers/RequestManager.js +161 -0
- package/dist/client/managers/RequestManager.js.map +1 -0
- package/dist/client/managers/index.d.ts +8 -0
- package/dist/client/managers/index.d.ts.map +1 -0
- package/dist/client/managers/index.js +8 -0
- package/dist/client/managers/index.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +264 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +7 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/auth.d.ts +44 -0
- package/dist/tools/auth.d.ts.map +1 -0
- package/dist/tools/auth.js +126 -0
- package/dist/tools/auth.js.map +1 -0
- package/dist/tools/base.d.ts +37 -0
- package/dist/tools/base.d.ts.map +1 -0
- package/dist/tools/base.js +60 -0
- package/dist/tools/base.js.map +1 -0
- package/dist/tools/comments.d.ts +33 -0
- package/dist/tools/comments.d.ts.map +1 -0
- package/dist/tools/comments.js +228 -0
- package/dist/tools/comments.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/media.d.ts +29 -0
- package/dist/tools/media.d.ts.map +1 -0
- package/dist/tools/media.js +208 -0
- package/dist/tools/media.js.map +1 -0
- package/dist/tools/pages.d.ts +30 -0
- package/dist/tools/pages.d.ts.map +1 -0
- package/dist/tools/pages.js +211 -0
- package/dist/tools/pages.js.map +1 -0
- package/dist/tools/posts.d.ts +30 -0
- package/dist/tools/posts.d.ts.map +1 -0
- package/dist/tools/posts.js +240 -0
- package/dist/tools/posts.js.map +1 -0
- package/dist/tools/site.d.ts +31 -0
- package/dist/tools/site.d.ts.map +1 -0
- package/dist/tools/site.js +192 -0
- package/dist/tools/site.js.map +1 -0
- package/dist/tools/taxonomies.d.ts +37 -0
- package/dist/tools/taxonomies.d.ts.map +1 -0
- package/dist/tools/taxonomies.js +280 -0
- package/dist/tools/taxonomies.js.map +1 -0
- package/dist/tools/users.d.ts +28 -0
- package/dist/tools/users.d.ts.map +1 -0
- package/dist/tools/users.js +201 -0
- package/dist/tools/users.js.map +1 -0
- package/dist/types/client.d.ts +215 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.js +72 -0
- package/dist/types/client.js.map +1 -0
- package/dist/types/index.d.ts +157 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mcp.d.ts +178 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +7 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/types/wordpress.d.ts +443 -0
- package/dist/types/wordpress.d.ts.map +1 -0
- package/dist/types/wordpress.js +7 -0
- package/dist/types/wordpress.js.map +1 -0
- package/dist/utils/debug.d.ts +63 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +195 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/error.d.ts +19 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +71 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/toolWrapper.d.ts +36 -0
- package/dist/utils/toolWrapper.d.ts.map +1 -0
- package/dist/utils/toolWrapper.js +90 -0
- package/dist/utils/toolWrapper.js.map +1 -0
- package/package.json +115 -0
- package/src/client/api.ts +1043 -0
- package/src/client/auth.ts +527 -0
- package/src/client/managers/AuthenticationManager.ts +190 -0
- package/src/client/managers/BaseManager.ts +73 -0
- package/src/client/managers/RequestManager.ts +214 -0
- package/src/client/managers/index.ts +8 -0
- package/src/index.ts +337 -0
- package/src/server.ts +7 -0
- package/src/tools/auth.ts +153 -0
- package/src/tools/comments.ts +263 -0
- package/src/tools/index.ts +8 -0
- package/src/tools/media.ts +240 -0
- package/src/tools/pages.ts +246 -0
- package/src/tools/posts.ts +277 -0
- package/src/tools/site.ts +227 -0
- package/src/tools/taxonomies.ts +322 -0
- package/src/tools/users.ts +233 -0
- package/src/types/client.ts +304 -0
- package/src/types/index.ts +207 -0
- package/src/types/mcp.ts +247 -0
- package/src/types/wordpress.ts +491 -0
- package/src/utils/debug.ts +258 -0
- package/src/utils/error.ts +88 -0
- package/src/utils/toolWrapper.ts +105 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Exports
|
|
3
|
+
*
|
|
4
|
+
* Central export point for all TypeScript types
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// WordPress API Types
|
|
8
|
+
export * from './wordpress.js';
|
|
9
|
+
|
|
10
|
+
// MCP Types
|
|
11
|
+
export * from './mcp.js';
|
|
12
|
+
|
|
13
|
+
// Client Types
|
|
14
|
+
export * from './client.js';
|
|
15
|
+
|
|
16
|
+
// Common Utility Types
|
|
17
|
+
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
18
|
+
export type RequiredKeys<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
19
|
+
export type Nullable<T> = T | null;
|
|
20
|
+
export type AsyncResult<T> = Promise<T>;
|
|
21
|
+
|
|
22
|
+
// Generic ID type
|
|
23
|
+
export type ID = number | string;
|
|
24
|
+
|
|
25
|
+
// Generic Error Response
|
|
26
|
+
export interface ErrorResponse {
|
|
27
|
+
error: true;
|
|
28
|
+
message: string;
|
|
29
|
+
code?: string;
|
|
30
|
+
details?: Record<string, any>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Generic Success Response
|
|
34
|
+
export interface SuccessResponse<T = any> {
|
|
35
|
+
success: true;
|
|
36
|
+
data: T;
|
|
37
|
+
message?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Combined Response Type
|
|
41
|
+
export type APIResult<T> = SuccessResponse<T> | ErrorResponse;
|
|
42
|
+
|
|
43
|
+
// Pagination Metadata
|
|
44
|
+
export interface PaginationMeta {
|
|
45
|
+
page: number;
|
|
46
|
+
per_page: number;
|
|
47
|
+
total: number;
|
|
48
|
+
total_pages: number;
|
|
49
|
+
has_next: boolean;
|
|
50
|
+
has_previous: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Paginated Response
|
|
54
|
+
export interface PaginatedResponse<T> {
|
|
55
|
+
data: T[];
|
|
56
|
+
meta: PaginationMeta;
|
|
57
|
+
links?: {
|
|
58
|
+
first?: string;
|
|
59
|
+
last?: string;
|
|
60
|
+
next?: string;
|
|
61
|
+
previous?: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Configuration Types
|
|
66
|
+
export interface DatabaseConfig {
|
|
67
|
+
host: string;
|
|
68
|
+
port: number;
|
|
69
|
+
name: string;
|
|
70
|
+
user: string;
|
|
71
|
+
password: string;
|
|
72
|
+
charset?: string;
|
|
73
|
+
collate?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface LoggingConfig {
|
|
77
|
+
level: 'debug' | 'info' | 'warn' | 'error';
|
|
78
|
+
file?: string;
|
|
79
|
+
console?: boolean;
|
|
80
|
+
format?: 'json' | 'text';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ServerConfig {
|
|
84
|
+
host: string;
|
|
85
|
+
port: number;
|
|
86
|
+
env: 'development' | 'production' | 'test';
|
|
87
|
+
debug: boolean;
|
|
88
|
+
logging: LoggingConfig;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Environment Variables Type
|
|
92
|
+
export interface Environment {
|
|
93
|
+
WORDPRESS_SITE_URL: string;
|
|
94
|
+
WORDPRESS_USERNAME: string;
|
|
95
|
+
WORDPRESS_APP_PASSWORD?: string;
|
|
96
|
+
WORDPRESS_PASSWORD?: string;
|
|
97
|
+
WORDPRESS_AUTH_METHOD: string;
|
|
98
|
+
WORDPRESS_JWT_SECRET?: string;
|
|
99
|
+
WORDPRESS_API_KEY?: string;
|
|
100
|
+
DEBUG?: string;
|
|
101
|
+
NODE_ENV?: string;
|
|
102
|
+
LOG_LEVEL?: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Validation Schema Types
|
|
106
|
+
export interface ValidationRule {
|
|
107
|
+
type: 'required' | 'string' | 'number' | 'boolean' | 'email' | 'url' | 'enum' | 'array' | 'object';
|
|
108
|
+
message?: string;
|
|
109
|
+
min?: number;
|
|
110
|
+
max?: number;
|
|
111
|
+
pattern?: RegExp;
|
|
112
|
+
enum_values?: any[];
|
|
113
|
+
custom?: (value: any) => boolean | string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface ValidationSchema {
|
|
117
|
+
[field: string]: ValidationRule | ValidationRule[];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Cache Types
|
|
121
|
+
export interface CacheEntry<T> {
|
|
122
|
+
value: T;
|
|
123
|
+
expiry: number;
|
|
124
|
+
created: number;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface CacheOptions {
|
|
128
|
+
ttl?: number; // time to live in milliseconds
|
|
129
|
+
maxSize?: number;
|
|
130
|
+
strategy?: 'lru' | 'fifo' | 'ttl';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Event Types
|
|
134
|
+
export interface EventData {
|
|
135
|
+
type: string;
|
|
136
|
+
timestamp: number;
|
|
137
|
+
data?: Record<string, any>;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type EventHandler<T = EventData> = (event: T) => void | Promise<void>;
|
|
141
|
+
|
|
142
|
+
// Performance Metrics
|
|
143
|
+
export interface PerformanceMetric {
|
|
144
|
+
name: string;
|
|
145
|
+
duration: number;
|
|
146
|
+
timestamp: number;
|
|
147
|
+
metadata?: Record<string, any>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Health Check Types
|
|
151
|
+
export interface HealthStatus {
|
|
152
|
+
status: 'healthy' | 'degraded' | 'unhealthy';
|
|
153
|
+
timestamp: number;
|
|
154
|
+
checks: Record<string, {
|
|
155
|
+
status: 'pass' | 'fail' | 'warn';
|
|
156
|
+
message?: string;
|
|
157
|
+
duration?: number;
|
|
158
|
+
}>;
|
|
159
|
+
uptime: number;
|
|
160
|
+
version: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Debugging Types
|
|
164
|
+
export interface DebugInfo {
|
|
165
|
+
timestamp: number;
|
|
166
|
+
level: 'debug' | 'info' | 'warn' | 'error';
|
|
167
|
+
message: string;
|
|
168
|
+
context?: Record<string, any>;
|
|
169
|
+
stack?: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Type Utilities
|
|
173
|
+
export type DeepPartial<T> = {
|
|
174
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export type DeepRequired<T> = {
|
|
178
|
+
[P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P];
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export type KeysOfType<T, U> = {
|
|
182
|
+
[K in keyof T]: T[K] extends U ? K : never;
|
|
183
|
+
}[keyof T];
|
|
184
|
+
|
|
185
|
+
export type Awaited<T> = T extends Promise<infer U> ? U : T;
|
|
186
|
+
|
|
187
|
+
// Brand types for better type safety
|
|
188
|
+
export type Brand<T, B> = T & { __brand: B };
|
|
189
|
+
|
|
190
|
+
export type WordPressID = Brand<number, 'WordPressID'>;
|
|
191
|
+
export type UserID = Brand<number, 'UserID'>;
|
|
192
|
+
export type PostID = Brand<number, 'PostID'>;
|
|
193
|
+
export type MediaID = Brand<number, 'MediaID'>;
|
|
194
|
+
export type CommentID = Brand<number, 'CommentID'>;
|
|
195
|
+
export type CategoryID = Brand<number, 'CategoryID'>;
|
|
196
|
+
export type TagID = Brand<number, 'TagID'>;
|
|
197
|
+
|
|
198
|
+
// Function Types
|
|
199
|
+
export type AsyncFunction<TArgs extends any[] = any[], TReturn = any> = (...args: TArgs) => Promise<TReturn>;
|
|
200
|
+
export type SyncFunction<TArgs extends any[] = any[], TReturn = any> = (...args: TArgs) => TReturn;
|
|
201
|
+
export type AnyFunction<TArgs extends any[] = any[], TReturn = any> = SyncFunction<TArgs, TReturn> | AsyncFunction<TArgs, TReturn>;
|
|
202
|
+
|
|
203
|
+
// Conditional Types
|
|
204
|
+
export type If<C extends boolean, T, F> = C extends true ? T : F;
|
|
205
|
+
export type IsEqual<T, U> = T extends U ? (U extends T ? true : false) : false;
|
|
206
|
+
export type IsArray<T> = T extends any[] ? true : false;
|
|
207
|
+
export type IsObject<T> = T extends object ? (T extends any[] ? false : true) : false;
|
package/src/types/mcp.ts
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Context Protocol (MCP) Types
|
|
3
|
+
*
|
|
4
|
+
* TypeScript definitions for MCP tools, requests, and responses
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
+
|
|
9
|
+
// MCP Tool Schema Types
|
|
10
|
+
export interface MCPToolSchema {
|
|
11
|
+
type: 'object';
|
|
12
|
+
properties: Record<string, JSONSchemaProperty>;
|
|
13
|
+
required?: string[];
|
|
14
|
+
additionalProperties?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface JSONSchemaProperty {
|
|
18
|
+
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
19
|
+
description?: string;
|
|
20
|
+
enum?: (string | number)[];
|
|
21
|
+
items?: JSONSchemaProperty;
|
|
22
|
+
properties?: Record<string, JSONSchemaProperty>;
|
|
23
|
+
minimum?: number;
|
|
24
|
+
maximum?: number;
|
|
25
|
+
minLength?: number;
|
|
26
|
+
maxLength?: number;
|
|
27
|
+
pattern?: string;
|
|
28
|
+
format?: string;
|
|
29
|
+
default?: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// MCP Tool Definition
|
|
33
|
+
export interface MCPTool {
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
inputSchema: MCPToolSchema;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// MCP Content Types
|
|
40
|
+
export interface MCPTextContent {
|
|
41
|
+
type: 'text';
|
|
42
|
+
text: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface MCPImageContent {
|
|
46
|
+
type: 'image';
|
|
47
|
+
data: string;
|
|
48
|
+
mimeType: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface MCPResourceContent {
|
|
52
|
+
type: 'resource';
|
|
53
|
+
resource: {
|
|
54
|
+
uri: string;
|
|
55
|
+
mimeType?: string;
|
|
56
|
+
text?: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type MCPContent = MCPTextContent | MCPImageContent | MCPResourceContent;
|
|
61
|
+
|
|
62
|
+
// MCP Response Types
|
|
63
|
+
export interface MCPToolResponse {
|
|
64
|
+
content: MCPContent[];
|
|
65
|
+
isError?: boolean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface MCPSuccessResponse extends MCPToolResponse {
|
|
69
|
+
isError?: false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface MCPErrorResponse extends MCPToolResponse {
|
|
73
|
+
isError: true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// MCP Tool Handler Type
|
|
77
|
+
export type MCPToolHandler<TArgs = any, TResponse = MCPToolResponse> = (
|
|
78
|
+
args: TArgs
|
|
79
|
+
) => Promise<TResponse>;
|
|
80
|
+
|
|
81
|
+
// Generic MCP Tool Handler with Client
|
|
82
|
+
export type MCPToolHandlerWithClient<TClient, TArgs = any, TResponse = MCPToolResponse> = (
|
|
83
|
+
client: TClient,
|
|
84
|
+
args: TArgs
|
|
85
|
+
) => Promise<TResponse>;
|
|
86
|
+
|
|
87
|
+
// MCP Request Types (based on SDK)
|
|
88
|
+
export type MCPListToolsRequest = typeof ListToolsRequestSchema;
|
|
89
|
+
export type MCPCallToolRequest = typeof CallToolRequestSchema;
|
|
90
|
+
|
|
91
|
+
// Tool Categories for Organization
|
|
92
|
+
export type MCPToolCategory =
|
|
93
|
+
| 'authentication'
|
|
94
|
+
| 'posts'
|
|
95
|
+
| 'pages'
|
|
96
|
+
| 'media'
|
|
97
|
+
| 'users'
|
|
98
|
+
| 'comments'
|
|
99
|
+
| 'taxonomies'
|
|
100
|
+
| 'site';
|
|
101
|
+
|
|
102
|
+
// Enhanced Tool Definition with Category
|
|
103
|
+
export interface CategorizedMCPTool extends MCPTool {
|
|
104
|
+
category: MCPToolCategory;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Tool Registry Type
|
|
108
|
+
export type MCPToolRegistry = Record<string, CategorizedMCPTool>;
|
|
109
|
+
|
|
110
|
+
// Handler Registry Type
|
|
111
|
+
export type MCPHandlerRegistry<TClient> = Record<string, MCPToolHandlerWithClient<TClient>>;
|
|
112
|
+
|
|
113
|
+
// Tool Validation Result
|
|
114
|
+
export interface ToolValidationResult {
|
|
115
|
+
valid: boolean;
|
|
116
|
+
errors: string[];
|
|
117
|
+
warnings: string[];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Common Response Helpers
|
|
121
|
+
export type CreateSuccessResponse = (text: string, additionalContent?: MCPContent[]) => MCPSuccessResponse;
|
|
122
|
+
export type CreateErrorResponse = (error: string | Error, additionalContent?: MCPContent[]) => MCPErrorResponse;
|
|
123
|
+
|
|
124
|
+
// Authentication Response Types
|
|
125
|
+
export interface AuthenticationResult {
|
|
126
|
+
success: boolean;
|
|
127
|
+
method: string;
|
|
128
|
+
message: string;
|
|
129
|
+
details?: Record<string, any>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Tool Execution Context
|
|
133
|
+
export interface MCPToolContext {
|
|
134
|
+
toolName: string;
|
|
135
|
+
category: MCPToolCategory;
|
|
136
|
+
startTime: number;
|
|
137
|
+
userId?: string;
|
|
138
|
+
sessionId?: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Tool Metrics
|
|
142
|
+
export interface MCPToolMetrics {
|
|
143
|
+
executionTime: number;
|
|
144
|
+
success: boolean;
|
|
145
|
+
errorType?: string;
|
|
146
|
+
inputSize?: number;
|
|
147
|
+
outputSize?: number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Enhanced Error Types
|
|
151
|
+
export interface MCPToolError extends Error {
|
|
152
|
+
toolName: string;
|
|
153
|
+
category: MCPToolCategory;
|
|
154
|
+
code?: string;
|
|
155
|
+
statusCode?: number;
|
|
156
|
+
details?: Record<string, any>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Tool Configuration
|
|
160
|
+
export interface MCPToolConfig {
|
|
161
|
+
timeout?: number;
|
|
162
|
+
retries?: number;
|
|
163
|
+
rateLimit?: {
|
|
164
|
+
requests: number;
|
|
165
|
+
window: number; // in milliseconds
|
|
166
|
+
};
|
|
167
|
+
validation?: {
|
|
168
|
+
strict: boolean;
|
|
169
|
+
allowAdditionalProperties: boolean;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Server Configuration
|
|
174
|
+
export interface MCPServerConfig {
|
|
175
|
+
name: string;
|
|
176
|
+
version: string;
|
|
177
|
+
tools: MCPToolRegistry;
|
|
178
|
+
handlers: MCPHandlerRegistry<any>;
|
|
179
|
+
middleware?: MCPMiddleware[];
|
|
180
|
+
config?: MCPToolConfig;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Middleware Type
|
|
184
|
+
export type MCPMiddleware<TClient = any> = (
|
|
185
|
+
context: MCPToolContext,
|
|
186
|
+
next: () => Promise<MCPToolResponse>
|
|
187
|
+
) => Promise<MCPToolResponse>;
|
|
188
|
+
|
|
189
|
+
// Tool Execution Pipeline
|
|
190
|
+
export interface MCPExecutionPipeline<TClient> {
|
|
191
|
+
validate: (toolName: string, args: any) => Promise<ToolValidationResult>;
|
|
192
|
+
authenticate: (client: TClient) => Promise<boolean>;
|
|
193
|
+
execute: (toolName: string, client: TClient, args: any) => Promise<MCPToolResponse>;
|
|
194
|
+
postProcess: (response: MCPToolResponse, context: MCPToolContext) => Promise<MCPToolResponse>;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Tool Documentation
|
|
198
|
+
export interface MCPToolDocumentation {
|
|
199
|
+
name: string;
|
|
200
|
+
category: MCPToolCategory;
|
|
201
|
+
description: string;
|
|
202
|
+
usage: string;
|
|
203
|
+
examples: Array<{
|
|
204
|
+
title: string;
|
|
205
|
+
description: string;
|
|
206
|
+
input: Record<string, any>;
|
|
207
|
+
output: string;
|
|
208
|
+
}>;
|
|
209
|
+
parameters: Array<{
|
|
210
|
+
name: string;
|
|
211
|
+
type: string;
|
|
212
|
+
required: boolean;
|
|
213
|
+
description: string;
|
|
214
|
+
example?: any;
|
|
215
|
+
}>;
|
|
216
|
+
errors: Array<{
|
|
217
|
+
code: string;
|
|
218
|
+
description: string;
|
|
219
|
+
resolution: string;
|
|
220
|
+
}>;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Batch Operation Types
|
|
224
|
+
export interface MCPBatchRequest {
|
|
225
|
+
operations: Array<{
|
|
226
|
+
toolName: string;
|
|
227
|
+
args: Record<string, any>;
|
|
228
|
+
id?: string;
|
|
229
|
+
}>;
|
|
230
|
+
parallel?: boolean;
|
|
231
|
+
stopOnError?: boolean;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface MCPBatchResponse {
|
|
235
|
+
results: Array<{
|
|
236
|
+
id?: string;
|
|
237
|
+
success: boolean;
|
|
238
|
+
response?: MCPToolResponse;
|
|
239
|
+
error?: MCPToolError;
|
|
240
|
+
}>;
|
|
241
|
+
summary: {
|
|
242
|
+
total: number;
|
|
243
|
+
successful: number;
|
|
244
|
+
failed: number;
|
|
245
|
+
executionTime: number;
|
|
246
|
+
};
|
|
247
|
+
}
|