mcp-use 1.0.2 → 1.0.3

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/dist/index.cjs CHANGED
@@ -496,7 +496,6 @@ __export(index_exports, {
496
496
  Telemetry: () => Telemetry,
497
497
  ToolMessage: () => import_messages3.ToolMessage,
498
498
  WebSocketConnector: () => WebSocketConnector,
499
- createMCPServer: () => createMCPServer,
500
499
  createOAuthMCPConfig: () => createOAuthMCPConfig,
501
500
  createReadableStreamFromGenerator: () => createReadableStreamFromGenerator,
502
501
  loadConfigFile: () => loadConfigFile,
@@ -4000,643 +3999,6 @@ async function* streamEventsToAISDKWithTools(streamEvents) {
4000
3999
  }
4001
4000
  __name(streamEventsToAISDKWithTools, "streamEventsToAISDKWithTools");
4002
4001
 
4003
- // src/server/mcp-server.ts
4004
- var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
4005
- var import_zod7 = require("zod");
4006
- var import_express = __toESM(require("express"), 1);
4007
- var import_node_fs3 = require("fs");
4008
- var import_node_path2 = require("path");
4009
-
4010
- // src/server/logging.ts
4011
- function requestLogger(req, res, next) {
4012
- const timestamp2 = (/* @__PURE__ */ new Date()).toISOString().substring(11, 23);
4013
- const method = req.method;
4014
- const url = req.url;
4015
- const originalEnd = res.end.bind(res);
4016
- res.end = function(chunk, encoding, cb) {
4017
- const statusCode = res.statusCode;
4018
- let statusColor = "";
4019
- if (statusCode >= 200 && statusCode < 300) {
4020
- statusColor = "\x1B[32m";
4021
- } else if (statusCode >= 300 && statusCode < 400) {
4022
- statusColor = "\x1B[33m";
4023
- } else if (statusCode >= 400 && statusCode < 500) {
4024
- statusColor = "\x1B[31m";
4025
- } else if (statusCode >= 500) {
4026
- statusColor = "\x1B[35m";
4027
- }
4028
- let logMessage = `[${timestamp2}] ${method} \x1B[1m${url}\x1B[0m`;
4029
- if (method === "POST" && url === "/mcp" && req.body?.method) {
4030
- logMessage += ` \x1B[1m[${req.body.method}]\x1B[0m`;
4031
- }
4032
- logMessage += ` ${statusColor}${statusCode}\x1B[0m`;
4033
- console.log(logMessage);
4034
- return originalEnd(chunk, encoding, cb);
4035
- };
4036
- next();
4037
- }
4038
- __name(requestLogger, "requestLogger");
4039
-
4040
- // src/server/mcp-server.ts
4041
- var McpServer = class {
4042
- static {
4043
- __name(this, "McpServer");
4044
- }
4045
- server;
4046
- config;
4047
- app;
4048
- mcpMounted = false;
4049
- inspectorMounted = false;
4050
- serverPort;
4051
- /**
4052
- * Creates a new MCP server instance with Express integration
4053
- *
4054
- * Initializes the server with the provided configuration, sets up CORS headers,
4055
- * configures widget serving routes, and creates a proxy that allows direct
4056
- * access to Express methods while preserving MCP server functionality.
4057
- *
4058
- * @param config - Server configuration including name, version, and description
4059
- * @returns A proxied McpServer instance that supports both MCP and Express methods
4060
- */
4061
- constructor(config2) {
4062
- this.config = config2;
4063
- this.server = new import_mcp.McpServer({
4064
- name: config2.name,
4065
- version: config2.version
4066
- });
4067
- this.app = (0, import_express.default)();
4068
- this.app.use(import_express.default.json());
4069
- this.app.use((req, res, next) => {
4070
- res.header("Access-Control-Allow-Origin", "*");
4071
- res.header("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
4072
- res.header("Access-Control-Allow-Headers", "Content-Type");
4073
- next();
4074
- });
4075
- this.app.use(requestLogger);
4076
- this.setupWidgetRoutes();
4077
- return new Proxy(this, {
4078
- get(target, prop) {
4079
- if (prop in target) {
4080
- return target[prop];
4081
- }
4082
- const value = target.app[prop];
4083
- return typeof value === "function" ? value.bind(target.app) : value;
4084
- }
4085
- });
4086
- }
4087
- /**
4088
- * Define a static resource that can be accessed by clients
4089
- *
4090
- * Registers a resource with the MCP server that clients can access via HTTP.
4091
- * Resources are static content like files, data, or pre-computed results that
4092
- * can be retrieved by clients without requiring parameters.
4093
- *
4094
- * @param resourceDefinition - Configuration object containing resource metadata and handler function
4095
- * @param resourceDefinition.name - Unique identifier for the resource
4096
- * @param resourceDefinition.uri - URI pattern for accessing the resource
4097
- * @param resourceDefinition.title - Optional human-readable title for the resource
4098
- * @param resourceDefinition.description - Optional description of the resource
4099
- * @param resourceDefinition.mimeType - MIME type of the resource content
4100
- * @param resourceDefinition.annotations - Optional annotations (audience, priority, lastModified)
4101
- * @param resourceDefinition.fn - Async function that returns the resource content
4102
- * @returns The server instance for method chaining
4103
- *
4104
- * @example
4105
- * ```typescript
4106
- * server.resource({
4107
- * name: 'config',
4108
- * uri: 'config://app-settings',
4109
- * title: 'Application Settings',
4110
- * mimeType: 'application/json',
4111
- * description: 'Current application configuration',
4112
- * annotations: {
4113
- * audience: ['user'],
4114
- * priority: 0.8
4115
- * },
4116
- * fn: async () => ({
4117
- * contents: [{
4118
- * uri: 'config://app-settings',
4119
- * mimeType: 'application/json',
4120
- * text: JSON.stringify({ theme: 'dark', language: 'en' })
4121
- * }]
4122
- * })
4123
- * })
4124
- * ```
4125
- */
4126
- resource(resourceDefinition) {
4127
- this.server.resource(
4128
- resourceDefinition.name,
4129
- resourceDefinition.uri,
4130
- {
4131
- name: resourceDefinition.name,
4132
- title: resourceDefinition.title,
4133
- description: resourceDefinition.description,
4134
- mimeType: resourceDefinition.mimeType,
4135
- annotations: resourceDefinition.annotations
4136
- },
4137
- async () => {
4138
- return await resourceDefinition.fn();
4139
- }
4140
- );
4141
- return this;
4142
- }
4143
- /**
4144
- * Define a dynamic resource template with parameters
4145
- *
4146
- * Registers a parameterized resource template with the MCP server. Templates use URI
4147
- * patterns with placeholders that can be filled in at request time, allowing dynamic
4148
- * resource generation based on parameters.
4149
- *
4150
- * @param resourceTemplateDefinition - Configuration object for the resource template
4151
- * @param resourceTemplateDefinition.name - Unique identifier for the template
4152
- * @param resourceTemplateDefinition.resourceTemplate - ResourceTemplate object with uriTemplate and metadata
4153
- * @param resourceTemplateDefinition.fn - Async function that generates resource content from URI and params
4154
- * @returns The server instance for method chaining
4155
- *
4156
- * @example
4157
- * ```typescript
4158
- * server.resourceTemplate({
4159
- * name: 'user-profile',
4160
- * resourceTemplate: {
4161
- * uriTemplate: 'user://{userId}/profile',
4162
- * name: 'User Profile',
4163
- * mimeType: 'application/json'
4164
- * },
4165
- * fn: async (uri, params) => ({
4166
- * contents: [{
4167
- * uri: uri.toString(),
4168
- * mimeType: 'application/json',
4169
- * text: JSON.stringify({ userId: params.userId, name: 'John Doe' })
4170
- * }]
4171
- * })
4172
- * })
4173
- * ```
4174
- */
4175
- resourceTemplate(resourceTemplateDefinition) {
4176
- const template = new import_mcp.ResourceTemplate(
4177
- resourceTemplateDefinition.resourceTemplate.uriTemplate,
4178
- {
4179
- list: void 0,
4180
- // Optional: callback to list all matching resources
4181
- complete: void 0
4182
- // Optional: callback for auto-completion
4183
- }
4184
- );
4185
- const metadata = {};
4186
- if (resourceTemplateDefinition.resourceTemplate.name) {
4187
- metadata.name = resourceTemplateDefinition.resourceTemplate.name;
4188
- }
4189
- if (resourceTemplateDefinition.title) {
4190
- metadata.title = resourceTemplateDefinition.title;
4191
- }
4192
- if (resourceTemplateDefinition.description || resourceTemplateDefinition.resourceTemplate.description) {
4193
- metadata.description = resourceTemplateDefinition.description || resourceTemplateDefinition.resourceTemplate.description;
4194
- }
4195
- if (resourceTemplateDefinition.resourceTemplate.mimeType) {
4196
- metadata.mimeType = resourceTemplateDefinition.resourceTemplate.mimeType;
4197
- }
4198
- if (resourceTemplateDefinition.annotations) {
4199
- metadata.annotations = resourceTemplateDefinition.annotations;
4200
- }
4201
- this.server.resource(
4202
- resourceTemplateDefinition.name,
4203
- template,
4204
- metadata,
4205
- async (uri) => {
4206
- const params = this.parseTemplateUri(
4207
- resourceTemplateDefinition.resourceTemplate.uriTemplate,
4208
- uri.toString()
4209
- );
4210
- return await resourceTemplateDefinition.fn(uri, params);
4211
- }
4212
- );
4213
- return this;
4214
- }
4215
- /**
4216
- * Define a tool that can be called by clients
4217
- *
4218
- * Registers a tool with the MCP server that clients can invoke with parameters.
4219
- * Tools are functions that perform actions, computations, or operations and
4220
- * return results. They accept structured input parameters and return structured output.
4221
- *
4222
- * @param toolDefinition - Configuration object containing tool metadata and handler function
4223
- * @param toolDefinition.name - Unique identifier for the tool
4224
- * @param toolDefinition.description - Human-readable description of what the tool does
4225
- * @param toolDefinition.inputs - Array of input parameter definitions with types and validation
4226
- * @param toolDefinition.fn - Async function that executes the tool logic with provided parameters
4227
- * @returns The server instance for method chaining
4228
- *
4229
- * @example
4230
- * ```typescript
4231
- * server.tool({
4232
- * name: 'calculate',
4233
- * description: 'Performs mathematical calculations',
4234
- * inputs: [
4235
- * { name: 'expression', type: 'string', required: true },
4236
- * { name: 'precision', type: 'number', required: false }
4237
- * ],
4238
- * fn: async ({ expression, precision = 2 }) => {
4239
- * const result = eval(expression)
4240
- * return { result: Number(result.toFixed(precision)) }
4241
- * }
4242
- * })
4243
- * ```
4244
- */
4245
- tool(toolDefinition) {
4246
- const inputSchema = this.createToolInputSchema(toolDefinition.inputs || []);
4247
- this.server.tool(
4248
- toolDefinition.name,
4249
- toolDefinition.description ?? "",
4250
- inputSchema,
4251
- async (params) => {
4252
- return await toolDefinition.fn(params);
4253
- }
4254
- );
4255
- return this;
4256
- }
4257
- /**
4258
- * Define a prompt template
4259
- *
4260
- * Registers a prompt template with the MCP server that clients can use to generate
4261
- * structured prompts for AI models. Prompt templates accept parameters and return
4262
- * formatted text that can be used as input to language models or other AI systems.
4263
- *
4264
- * @param promptDefinition - Configuration object containing prompt metadata and handler function
4265
- * @param promptDefinition.name - Unique identifier for the prompt template
4266
- * @param promptDefinition.description - Human-readable description of the prompt's purpose
4267
- * @param promptDefinition.args - Array of argument definitions with types and validation
4268
- * @param promptDefinition.fn - Async function that generates the prompt from provided arguments
4269
- * @returns The server instance for method chaining
4270
- *
4271
- * @example
4272
- * ```typescript
4273
- * server.prompt({
4274
- * name: 'code-review',
4275
- * description: 'Generates a code review prompt',
4276
- * args: [
4277
- * { name: 'language', type: 'string', required: true },
4278
- * { name: 'focus', type: 'string', required: false }
4279
- * ],
4280
- * fn: async ({ language, focus = 'general' }) => {
4281
- * return {
4282
- * messages: [{
4283
- * role: 'user',
4284
- * content: `Please review this ${language} code with focus on ${focus}...`
4285
- * }]
4286
- * }
4287
- * }
4288
- * })
4289
- * ```
4290
- */
4291
- prompt(promptDefinition) {
4292
- const argsSchema = this.createPromptArgsSchema(promptDefinition.args || []);
4293
- this.server.prompt(
4294
- promptDefinition.name,
4295
- promptDefinition.description ?? "",
4296
- argsSchema,
4297
- async (params) => {
4298
- return await promptDefinition.fn(params);
4299
- }
4300
- );
4301
- return this;
4302
- }
4303
- /**
4304
- * Mount MCP server endpoints at /mcp
4305
- *
4306
- * Sets up the HTTP transport layer for the MCP server, creating endpoints for
4307
- * Server-Sent Events (SSE) streaming, POST message handling, and DELETE session cleanup.
4308
- * Uses stateless mode for session management, making it suitable for stateless deployments.
4309
- *
4310
- * This method is called automatically when the server starts listening and ensures
4311
- * that MCP clients can communicate with the server over HTTP.
4312
- *
4313
- * @private
4314
- * @returns Promise that resolves when MCP endpoints are successfully mounted
4315
- *
4316
- * @example
4317
- * Endpoints created:
4318
- * - GET /mcp - SSE streaming endpoint for real-time communication
4319
- * - POST /mcp - Message handling endpoint for MCP protocol messages
4320
- * - DELETE /mcp - Session cleanup endpoint
4321
- */
4322
- async mountMcp() {
4323
- if (this.mcpMounted) return;
4324
- const { StreamableHTTPServerTransport } = await import("@modelcontextprotocol/sdk/server/streamableHttp.js");
4325
- const httpTransport = new StreamableHTTPServerTransport({
4326
- sessionIdGenerator: void 0
4327
- // Stateless mode
4328
- });
4329
- await this.server.connect(httpTransport);
4330
- const endpoint = "/mcp";
4331
- this.app.get(endpoint, async (req, res) => {
4332
- await httpTransport.handleRequest(req, res);
4333
- });
4334
- this.app.post(endpoint, import_express.default.json(), async (req, res) => {
4335
- await httpTransport.handleRequest(req, res, req.body);
4336
- });
4337
- this.app.delete(endpoint, async (req, res) => {
4338
- await httpTransport.handleRequest(req, res);
4339
- });
4340
- this.mcpMounted = true;
4341
- console.log(`[MCP] Server mounted at ${endpoint}`);
4342
- }
4343
- /**
4344
- * Start the Express server with MCP endpoints
4345
- *
4346
- * Initiates the server startup process by mounting MCP endpoints, configuring
4347
- * the inspector UI (if available), and starting the Express server to listen
4348
- * for incoming connections. This is the main entry point for running the server.
4349
- *
4350
- * The server will be accessible at the specified port with MCP endpoints at /mcp
4351
- * and inspector UI at /inspector (if the inspector package is installed).
4352
- *
4353
- * @param port - Port number to listen on (defaults to 3001 if not specified)
4354
- * @returns Promise that resolves when the server is successfully listening
4355
- *
4356
- * @example
4357
- * ```typescript
4358
- * await server.listen(8080)
4359
- * // Server now running at http://localhost:8080
4360
- * // MCP endpoints: http://localhost:8080/mcp
4361
- * // Inspector UI: http://localhost:8080/inspector
4362
- * ```
4363
- */
4364
- async listen(port) {
4365
- await this.mountMcp();
4366
- this.serverPort = port || 3001;
4367
- this.mountInspector();
4368
- this.app.listen(this.serverPort, () => {
4369
- console.log(`[SERVER] Listening on http://localhost:${this.serverPort}`);
4370
- console.log(`[MCP] Endpoints: http://localhost:${this.serverPort}/mcp`);
4371
- });
4372
- }
4373
- /**
4374
- * Mount MCP Inspector UI at /inspector
4375
- *
4376
- * Dynamically loads and mounts the MCP Inspector UI package if available, providing
4377
- * a web-based interface for testing and debugging MCP servers. The inspector
4378
- * automatically connects to the local MCP server endpoints.
4379
- *
4380
- * This method gracefully handles cases where the inspector package is not installed,
4381
- * allowing the server to function without the inspector in production environments.
4382
- *
4383
- * @private
4384
- * @returns void
4385
- *
4386
- * @example
4387
- * If @mcp-use/inspector is installed:
4388
- * - Inspector UI available at http://localhost:PORT/inspector
4389
- * - Automatically connects to http://localhost:PORT/mcp
4390
- *
4391
- * If not installed:
4392
- * - Server continues to function normally
4393
- * - No inspector UI available
4394
- */
4395
- mountInspector() {
4396
- if (this.inspectorMounted) return;
4397
- import("@mcp-use/inspector").then(({ mountInspector }) => {
4398
- const mcpServerUrl = `http://localhost:${this.serverPort}/mcp`;
4399
- mountInspector(this.app, "/inspector", mcpServerUrl);
4400
- this.inspectorMounted = true;
4401
- console.log(`[INSPECTOR] UI available at http://localhost:${this.serverPort}/inspector`);
4402
- }).catch(() => {
4403
- });
4404
- }
4405
- /**
4406
- * Setup default widget serving routes
4407
- *
4408
- * Configures Express routes to serve MCP UI widgets and their static assets.
4409
- * Widgets are served from the dist/resources/mcp-use/widgets directory and can
4410
- * be accessed via HTTP endpoints for embedding in web applications.
4411
- *
4412
- * Routes created:
4413
- * - GET /mcp-use/widgets/:widget - Serves widget's index.html
4414
- * - GET /mcp-use/widgets/:widget/assets/* - Serves widget-specific assets
4415
- * - GET /mcp-use/widgets/assets/* - Fallback asset serving with auto-discovery
4416
- *
4417
- * @private
4418
- * @returns void
4419
- *
4420
- * @example
4421
- * Widget routes:
4422
- * - http://localhost:3001/mcp-use/widgets/kanban-board
4423
- * - http://localhost:3001/mcp-use/widgets/todo-list/assets/style.css
4424
- * - http://localhost:3001/mcp-use/widgets/assets/script.js (auto-discovered)
4425
- */
4426
- setupWidgetRoutes() {
4427
- this.app.get("/mcp-use/widgets/:widget/assets/*", (req, res, next) => {
4428
- const widget = req.params.widget;
4429
- const assetFile = req.params[0];
4430
- const assetPath = (0, import_node_path2.join)(process.cwd(), "dist", "resources", "mcp-use", "widgets", widget, "assets", assetFile);
4431
- res.sendFile(assetPath, (err) => err ? next() : void 0);
4432
- });
4433
- this.app.get("/mcp-use/widgets/assets/*", (req, res, next) => {
4434
- const assetFile = req.params[0];
4435
- const widgetsDir = (0, import_node_path2.join)(process.cwd(), "dist", "resources", "mcp-use", "widgets");
4436
- try {
4437
- const widgets = (0, import_node_fs3.readdirSync)(widgetsDir);
4438
- for (const widget of widgets) {
4439
- const assetPath = (0, import_node_path2.join)(widgetsDir, widget, "assets", assetFile);
4440
- if ((0, import_node_fs3.existsSync)(assetPath)) {
4441
- return res.sendFile(assetPath);
4442
- }
4443
- }
4444
- next();
4445
- } catch {
4446
- next();
4447
- }
4448
- });
4449
- this.app.get("/mcp-use/widgets/:widget", (req, res, next) => {
4450
- const filePath = (0, import_node_path2.join)(process.cwd(), "dist", "resources", "mcp-use", "widgets", req.params.widget, "index.html");
4451
- res.sendFile(filePath, (err) => err ? next() : void 0);
4452
- });
4453
- }
4454
- /**
4455
- * Create input schema for resource templates
4456
- *
4457
- * Parses a URI template string to extract parameter names and generates a Zod
4458
- * validation schema for those parameters. Used internally for validating resource
4459
- * template parameters before processing requests.
4460
- *
4461
- * @param uriTemplate - URI template string with parameter placeholders (e.g., "/users/{id}/posts/{postId}")
4462
- * @returns Object mapping parameter names to Zod string schemas
4463
- *
4464
- * @example
4465
- * ```typescript
4466
- * const schema = this.createInputSchema("/users/{id}/posts/{postId}")
4467
- * // Returns: { id: z.string(), postId: z.string() }
4468
- * ```
4469
- */
4470
- createInputSchema(uriTemplate) {
4471
- const params = this.extractTemplateParams(uriTemplate);
4472
- const schema = {};
4473
- params.forEach((param) => {
4474
- schema[param] = import_zod7.z.string();
4475
- });
4476
- return schema;
4477
- }
4478
- /**
4479
- * Create input schema for tools
4480
- *
4481
- * Converts tool input definitions into Zod validation schemas for runtime validation.
4482
- * Supports common data types (string, number, boolean, object, array) and optional
4483
- * parameters. Used internally when registering tools with the MCP server.
4484
- *
4485
- * @param inputs - Array of input parameter definitions with name, type, and optional flag
4486
- * @returns Object mapping parameter names to Zod validation schemas
4487
- *
4488
- * @example
4489
- * ```typescript
4490
- * const schema = this.createToolInputSchema([
4491
- * { name: 'query', type: 'string', required: true },
4492
- * { name: 'limit', type: 'number', required: false }
4493
- * ])
4494
- * // Returns: { query: z.string(), limit: z.number().optional() }
4495
- * ```
4496
- */
4497
- createToolInputSchema(inputs) {
4498
- const schema = {};
4499
- inputs.forEach((input) => {
4500
- let zodType;
4501
- switch (input.type) {
4502
- case "string":
4503
- zodType = import_zod7.z.string();
4504
- break;
4505
- case "number":
4506
- zodType = import_zod7.z.number();
4507
- break;
4508
- case "boolean":
4509
- zodType = import_zod7.z.boolean();
4510
- break;
4511
- case "object":
4512
- zodType = import_zod7.z.object({});
4513
- break;
4514
- case "array":
4515
- zodType = import_zod7.z.array(import_zod7.z.any());
4516
- break;
4517
- default:
4518
- zodType = import_zod7.z.any();
4519
- }
4520
- if (!input.required) {
4521
- zodType = zodType.optional();
4522
- }
4523
- schema[input.name] = zodType;
4524
- });
4525
- return schema;
4526
- }
4527
- /**
4528
- * Create arguments schema for prompts
4529
- *
4530
- * Converts prompt argument definitions into Zod validation schemas for runtime validation.
4531
- * Supports common data types (string, number, boolean, object, array) and optional
4532
- * parameters. Used internally when registering prompt templates with the MCP server.
4533
- *
4534
- * @param inputs - Array of argument definitions with name, type, and optional flag
4535
- * @returns Object mapping argument names to Zod validation schemas
4536
- *
4537
- * @example
4538
- * ```typescript
4539
- * const schema = this.createPromptArgsSchema([
4540
- * { name: 'topic', type: 'string', required: true },
4541
- * { name: 'style', type: 'string', required: false }
4542
- * ])
4543
- * // Returns: { topic: z.string(), style: z.string().optional() }
4544
- * ```
4545
- */
4546
- createPromptArgsSchema(inputs) {
4547
- const schema = {};
4548
- inputs.forEach((input) => {
4549
- let zodType;
4550
- switch (input.type) {
4551
- case "string":
4552
- zodType = import_zod7.z.string();
4553
- break;
4554
- case "number":
4555
- zodType = import_zod7.z.number();
4556
- break;
4557
- case "boolean":
4558
- zodType = import_zod7.z.boolean();
4559
- break;
4560
- case "object":
4561
- zodType = import_zod7.z.object({});
4562
- break;
4563
- case "array":
4564
- zodType = import_zod7.z.array(import_zod7.z.any());
4565
- break;
4566
- default:
4567
- zodType = import_zod7.z.any();
4568
- }
4569
- if (!input.required) {
4570
- zodType = zodType.optional();
4571
- }
4572
- schema[input.name] = zodType;
4573
- });
4574
- return schema;
4575
- }
4576
- /**
4577
- * Extract parameter names from URI template
4578
- *
4579
- * Parses a URI template string to extract parameter names enclosed in curly braces.
4580
- * Used internally to identify dynamic parameters in resource templates and generate
4581
- * appropriate validation schemas.
4582
- *
4583
- * @param uriTemplate - URI template string with parameter placeholders (e.g., "/users/{id}/posts/{postId}")
4584
- * @returns Array of parameter names found in the template
4585
- *
4586
- * @example
4587
- * ```typescript
4588
- * const params = this.extractTemplateParams("/users/{id}/posts/{postId}")
4589
- * // Returns: ["id", "postId"]
4590
- * ```
4591
- */
4592
- extractTemplateParams(uriTemplate) {
4593
- const matches = uriTemplate.match(/\{([^}]+)\}/g);
4594
- return matches ? matches.map((match) => match.slice(1, -1)) : [];
4595
- }
4596
- /**
4597
- * Parse parameter values from a URI based on a template
4598
- *
4599
- * Extracts parameter values from an actual URI by matching it against a URI template.
4600
- * The template contains placeholders like {param} which are extracted as key-value pairs.
4601
- *
4602
- * @param template - URI template with placeholders (e.g., "user://{userId}/posts/{postId}")
4603
- * @param uri - Actual URI to parse (e.g., "user://123/posts/456")
4604
- * @returns Object mapping parameter names to their values
4605
- *
4606
- * @example
4607
- * ```typescript
4608
- * const params = this.parseTemplateUri("user://{userId}/posts/{postId}", "user://123/posts/456")
4609
- * // Returns: { userId: "123", postId: "456" }
4610
- * ```
4611
- */
4612
- parseTemplateUri(template, uri) {
4613
- const params = {};
4614
- let regexPattern = template.replace(/[.*+?^$()[\]\\|]/g, "\\$&");
4615
- const paramNames = [];
4616
- regexPattern = regexPattern.replace(/\\\{([^}]+)\\\}/g, (_, paramName) => {
4617
- paramNames.push(paramName);
4618
- return "([^/]+)";
4619
- });
4620
- const regex = new RegExp(`^${regexPattern}$`);
4621
- const match = uri.match(regex);
4622
- if (match) {
4623
- paramNames.forEach((paramName, index) => {
4624
- params[paramName] = match[index + 1];
4625
- });
4626
- }
4627
- return params;
4628
- }
4629
- };
4630
- function createMCPServer(name, config2 = {}) {
4631
- const instance = new McpServer({
4632
- name,
4633
- version: config2.version || "1.0.0",
4634
- description: config2.description
4635
- });
4636
- return instance;
4637
- }
4638
- __name(createMCPServer, "createMCPServer");
4639
-
4640
4002
  // src/oauth-helper.ts
4641
4003
  var OAuthHelper = class {
4642
4004
  static {
@@ -5985,7 +5347,6 @@ var import_messages3 = require("@langchain/core/messages");
5985
5347
  Telemetry,
5986
5348
  ToolMessage,
5987
5349
  WebSocketConnector,
5988
- createMCPServer,
5989
5350
  createOAuthMCPConfig,
5990
5351
  createReadableStreamFromGenerator,
5991
5352
  loadConfigFile,
package/dist/index.d.ts CHANGED
@@ -13,8 +13,6 @@ export * from './src/agents/utils/index.js';
13
13
  export { ServerManager } from './src/managers/server_manager.js';
14
14
  export * from './src/managers/tools/index.js';
15
15
  export { type ObservabilityConfig, ObservabilityManager } from './src/observability/index.js';
16
- export { createMCPServer } from './src/server/index.js';
17
- export type { InputDefinition, PromptDefinition, PromptHandler, ResourceDefinition, ResourceHandler, ServerConfig, ToolDefinition, ToolHandler, } from './src/server/types.js';
18
16
  export { setTelemetrySource, Telemetry } from './src/telemetry/index.js';
19
17
  export { OAuthHelper, LINEAR_OAUTH_CONFIG, createOAuthMCPConfig } from './src/oauth-helper.js';
20
18
  export type { OAuthConfig, OAuthDiscovery, ClientRegistration, OAuthResult, OAuthState } from './src/oauth-helper.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,WAAW,EAAE,gBAAgB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E,MAAM,oCAAoC,CAAA;AAErE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAA"}
package/dist/index.js CHANGED
@@ -5,9 +5,6 @@ import {
5
5
  BrowserOAuthClientProvider,
6
6
  onMcpAuthorization
7
7
  } from "./chunk-TJXUCAST.js";
8
- import {
9
- createMCPServer
10
- } from "./chunk-MZPKOZE4.js";
11
8
  import {
12
9
  Logger,
13
10
  logger
@@ -3877,7 +3874,6 @@ export {
3877
3874
  Telemetry,
3878
3875
  ToolMessage2 as ToolMessage,
3879
3876
  WebSocketConnector,
3880
- createMCPServer,
3881
3877
  createOAuthMCPConfig,
3882
3878
  createReadableStreamFromGenerator,
3883
3879
  loadConfigFile,