@ttoss/http-server-mcp 0.35.0 → 0.37.0

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/README.md CHANGED
@@ -357,7 +357,7 @@ createMcpRouter(mcpServer, {
357
357
  });
358
358
  ```
359
359
 
360
- The `resource` field in the metadata document is automatically set to `resourceServerUrl + path` (e.g. `https://mcp.example.com/mcp` for the default path). This means MCP clients that follow `resource` to connect will land on the actual MCP endpoint rather than the bare origin.
360
+ The `resource` field in the metadata document is automatically set to `resourceServerUrl + path` (e.g. `https://mcp.example.com/mcp` for the default path). This means MCP clients that follow `resource` to connect will land on the actual MCP endpoint rather than the bare origin. Add `scopesSupported` to advertise the scopes this server accepts as `scopes_supported`, so clients request only what they need; unlike `requiredScopes`, it enforces nothing.
361
361
 
362
362
  **With your own auth middleware** — use `createProtectedResourceMetadataMiddleware` as a standalone middleware, mounted _before_ your auth layer so discovery stays unauthenticated:
363
363
 
@@ -1155,7 +1155,7 @@ test('every tool the instructions name exists', () => {
1155
1155
  });
1156
1156
  ```
1157
1157
 
1158
- Sizes are characters of `JSON.stringify({ name, description, inputSchema })`; `measureMcpSurface` answers them without judging. `total` and `perTool` have no default — they are the product's choice — while `instructions` defaults to `2048`, about what Claude Code keeps before cutting the rest silently. `findUnknownToolMentions` reads backticked names with a `-` or `_` (`` `get-next` ``); pass `pattern` when the instructions name tools another way.
1158
+ Sizes are characters of `JSON.stringify({ name, description, inputSchema })`; `measureMcpSurface` answers them without judging. `total` and `perTool` have no default — they are the product's choice. `description` (each tool's description alone) and `instructions` default to `2048`, where [Claude Code truncates both](https://code.claude.com/docs/en/mcp) without saying so; a schema is never cut, which is why `perTool` cannot stand in for `description`. `findUnknownToolMentions` reads backticked names with a `-` or `_` (`` `get-next` ``); pass `pattern` when the instructions name tools another way.
1159
1159
 
1160
1160
  ## AWS Lambda Deployment
1161
1161
 
package/dist/index.cjs CHANGED
@@ -215,11 +215,17 @@ var createMcpRequestServer = ({
215
215
  //#endregion
216
216
  //#region src/mcpSurface.ts
217
217
  /**
218
- * Claude Code keeps about this many characters of a server's instructions and
219
- * drops the rest without telling anyone, so a rule past it never reaches an
220
- * agent.
218
+ * Claude Code truncates a server's instructions at this many characters
219
+ * without telling anyone, so a rule past it never reaches an agent
220
+ * (https://code.claude.com/docs/en/mcp; a user can change it with
221
+ * `CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH`).
221
222
  */
222
223
  var DEFAULT_INSTRUCTIONS_LIMIT = 2048;
224
+ /**
225
+ * Claude Code truncates each tool description at the same length as the
226
+ * instructions, from the same documentation, and just as silently.
227
+ */
228
+ var DEFAULT_DESCRIPTION_LIMIT = 2048;
223
229
  var sizeOf = tool => {
224
230
  return JSON.stringify({
225
231
  name: tool.name,
@@ -254,6 +260,20 @@ var measureMcpSurface = ({
254
260
  instructions: instructions?.length ?? 0
255
261
  };
256
262
  };
263
+ var checkDescriptions = ({
264
+ tools,
265
+ limit
266
+ }) => {
267
+ return tools.flatMap(tool => {
268
+ const size = tool.description?.length ?? 0;
269
+ return size > limit ? [{
270
+ kind: "description",
271
+ name: tool.name,
272
+ size,
273
+ limit
274
+ }] : [];
275
+ });
276
+ };
257
277
  /**
258
278
  * Every limit an MCP surface exceeds, or `[]` when it fits.
259
279
  *
@@ -298,6 +318,10 @@ var checkMcpSurface = ({
298
318
  limit: budget.perTool
299
319
  });
300
320
  }
321
+ violations.push(...checkDescriptions({
322
+ tools,
323
+ limit: budget.description ?? 2048
324
+ }));
301
325
  const instructionsLimit = budget.instructions ?? 2048;
302
326
  if (report.instructions > instructionsLimit) violations.push({
303
327
  kind: "instructions",
@@ -1592,7 +1616,8 @@ var createMcpRouter = (server, options = {}) => {
1592
1616
  const metadata = resourceUrl !== void 0 && auth.authorizationServerUrl !== void 0 ? {
1593
1617
  document: (0, _ttoss_auth_core.protectedResourceMetadataDocument)({
1594
1618
  resource: resourceUrl,
1595
- authorizationServers: [auth.authorizationServerUrl]
1619
+ authorizationServers: [auth.authorizationServerUrl],
1620
+ scopesSupported: auth.scopesSupported
1596
1621
  }),
1597
1622
  paths: (0, _ttoss_auth_core.protectedResourceMetadataPaths)({
1598
1623
  resource: resourceUrl
@@ -1689,6 +1714,7 @@ var createMcpRouter = (server, options = {}) => {
1689
1714
  };
1690
1715
 
1691
1716
  //#endregion
1717
+ exports.DEFAULT_DESCRIPTION_LIMIT = DEFAULT_DESCRIPTION_LIMIT;
1692
1718
  exports.DEFAULT_INSTRUCTIONS_LIMIT = DEFAULT_INSTRUCTIONS_LIMIT;
1693
1719
  Object.defineProperty(exports, 'InMemoryServerEventBus', {
1694
1720
  enumerable: true,
package/dist/index.d.cts CHANGED
@@ -910,14 +910,21 @@ interface McpSurfaceReport {
910
910
  instructions: number;
911
911
  }
912
912
  /**
913
- * The limits a surface is checked against. Only `instructions` has a default:
914
- * the others are a product's own choice, not a property of any client.
913
+ * The limits a surface is checked against. `description` and `instructions`
914
+ * have defaults, because a client cuts them; `total` and `perTool` are a
915
+ * product's own choice, not a property of any client.
915
916
  */
916
917
  interface McpSurfaceBudget {
917
918
  /** Ceiling on the sum of every tool's size. */
918
919
  total?: number;
919
920
  /** Ceiling on any one tool's size. */
920
921
  perTool?: number;
922
+ /**
923
+ * Ceiling on any one tool's description length. Unlike `perTool`, it leaves
924
+ * out the name and input schema, which no client cuts.
925
+ * @default 2048
926
+ */
927
+ description?: number;
921
928
  /**
922
929
  * Ceiling on the instructions' length.
923
930
  * @default 2048
@@ -934,17 +941,28 @@ type McpSurfaceViolation = {
934
941
  name: string;
935
942
  size: number;
936
943
  limit: number;
944
+ } | {
945
+ kind: 'description';
946
+ name: string;
947
+ size: number;
948
+ limit: number;
937
949
  } | {
938
950
  kind: 'instructions';
939
951
  size: number;
940
952
  limit: number;
941
953
  };
942
954
  /**
943
- * Claude Code keeps about this many characters of a server's instructions and
944
- * drops the rest without telling anyone, so a rule past it never reaches an
945
- * agent.
955
+ * Claude Code truncates a server's instructions at this many characters
956
+ * without telling anyone, so a rule past it never reaches an agent
957
+ * (https://code.claude.com/docs/en/mcp; a user can change it with
958
+ * `CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH`).
946
959
  */
947
960
  declare const DEFAULT_INSTRUCTIONS_LIMIT = 2048;
961
+ /**
962
+ * Claude Code truncates each tool description at the same length as the
963
+ * instructions, from the same documentation, and just as silently.
964
+ */
965
+ declare const DEFAULT_DESCRIPTION_LIMIT = 2048;
948
966
  /**
949
967
  * Measures what an MCP server costs every session that connects to it: each
950
968
  * tool's name, description and input schema, and the instructions.
@@ -1500,6 +1518,12 @@ interface McpAuthOptions {
1500
1518
  resourceServerUrl?: string;
1501
1519
  /** URL of the OAuth Authorization Server that issues tokens for this resource. */
1502
1520
  authorizationServerUrl?: string;
1521
+ /**
1522
+ * Scopes this MCP server accepts, advertised as `scopes_supported` in the
1523
+ * Protected Resource Metadata document so clients request only what they
1524
+ * need. Unlike `requiredScopes`, nothing is enforced from it.
1525
+ */
1526
+ scopesSupported?: string[];
1503
1527
  /**
1504
1528
  * Expected audience — the resource indicator (RFC 8707) this MCP server
1505
1529
  * identifies as. When set, the verified token's `aud` claim must include at
@@ -1829,4 +1853,4 @@ interface McpRouterOptions {
1829
1853
  */
1830
1854
  declare const createMcpRouter: (server: McpServer$1, options?: McpRouterOptions) => McpRouter;
1831
1855
  //#endregion
1832
- export { ApiCallOptions, CognitoUserPoolConfig, type CreateToolGateOptions, DEFAULT_INSTRUCTIONS_LIMIT, type DeferToolsOptions, type DefineToolParams, type GateToolParams, InMemoryServerEventBus, type JsonObjectSchema, McpAuthOptions, McpRouter, McpRouterOptions, McpServer, type McpSurfaceBudget, type McpSurfaceReport, type McpSurfaceTool, type McpSurfaceViolation, type RegisterAppResourceParams, type RegisterToolsParams, type RegisteredAppResource, type ServerEvent, type ServerEventBus, type ServerNotifier, type Tool, type ToolCallContext, type ToolCallGate, type ToolGate, type ToolIdentity, type ToolMetaParams, type ToolSchema, type ToolSearchArgs, UI_EXTENSION_ID, UI_RESOURCE_MIME_TYPE, type UiResourceCsp, type UiResourceMeta, type UiResourcePermissions, type UiToolVisibility, apiCall, checkMcpSurface, checkScopes, createMcpRouter, createToolGate, defineTool, errorBodyMessage, findUnknownToolMentions, getApiHeaders, getIdentity, getRequestLocale, measureMcpSurface, rankTools, registerAppResource, registerTools, z };
1856
+ export { ApiCallOptions, CognitoUserPoolConfig, type CreateToolGateOptions, DEFAULT_DESCRIPTION_LIMIT, DEFAULT_INSTRUCTIONS_LIMIT, type DeferToolsOptions, type DefineToolParams, type GateToolParams, InMemoryServerEventBus, type JsonObjectSchema, McpAuthOptions, McpRouter, McpRouterOptions, McpServer, type McpSurfaceBudget, type McpSurfaceReport, type McpSurfaceTool, type McpSurfaceViolation, type RegisterAppResourceParams, type RegisterToolsParams, type RegisteredAppResource, type ServerEvent, type ServerEventBus, type ServerNotifier, type Tool, type ToolCallContext, type ToolCallGate, type ToolGate, type ToolIdentity, type ToolMetaParams, type ToolSchema, type ToolSearchArgs, UI_EXTENSION_ID, UI_RESOURCE_MIME_TYPE, type UiResourceCsp, type UiResourceMeta, type UiResourcePermissions, type UiToolVisibility, apiCall, checkMcpSurface, checkScopes, createMcpRouter, createToolGate, defineTool, errorBodyMessage, findUnknownToolMentions, getApiHeaders, getIdentity, getRequestLocale, measureMcpSurface, rankTools, registerAppResource, registerTools, z };
package/dist/index.d.mts CHANGED
@@ -911,14 +911,21 @@ interface McpSurfaceReport {
911
911
  instructions: number;
912
912
  }
913
913
  /**
914
- * The limits a surface is checked against. Only `instructions` has a default:
915
- * the others are a product's own choice, not a property of any client.
914
+ * The limits a surface is checked against. `description` and `instructions`
915
+ * have defaults, because a client cuts them; `total` and `perTool` are a
916
+ * product's own choice, not a property of any client.
916
917
  */
917
918
  interface McpSurfaceBudget {
918
919
  /** Ceiling on the sum of every tool's size. */
919
920
  total?: number;
920
921
  /** Ceiling on any one tool's size. */
921
922
  perTool?: number;
923
+ /**
924
+ * Ceiling on any one tool's description length. Unlike `perTool`, it leaves
925
+ * out the name and input schema, which no client cuts.
926
+ * @default 2048
927
+ */
928
+ description?: number;
922
929
  /**
923
930
  * Ceiling on the instructions' length.
924
931
  * @default 2048
@@ -935,17 +942,28 @@ type McpSurfaceViolation = {
935
942
  name: string;
936
943
  size: number;
937
944
  limit: number;
945
+ } | {
946
+ kind: 'description';
947
+ name: string;
948
+ size: number;
949
+ limit: number;
938
950
  } | {
939
951
  kind: 'instructions';
940
952
  size: number;
941
953
  limit: number;
942
954
  };
943
955
  /**
944
- * Claude Code keeps about this many characters of a server's instructions and
945
- * drops the rest without telling anyone, so a rule past it never reaches an
946
- * agent.
956
+ * Claude Code truncates a server's instructions at this many characters
957
+ * without telling anyone, so a rule past it never reaches an agent
958
+ * (https://code.claude.com/docs/en/mcp; a user can change it with
959
+ * `CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH`).
947
960
  */
948
961
  declare const DEFAULT_INSTRUCTIONS_LIMIT = 2048;
962
+ /**
963
+ * Claude Code truncates each tool description at the same length as the
964
+ * instructions, from the same documentation, and just as silently.
965
+ */
966
+ declare const DEFAULT_DESCRIPTION_LIMIT = 2048;
949
967
  /**
950
968
  * Measures what an MCP server costs every session that connects to it: each
951
969
  * tool's name, description and input schema, and the instructions.
@@ -1501,6 +1519,12 @@ interface McpAuthOptions {
1501
1519
  resourceServerUrl?: string;
1502
1520
  /** URL of the OAuth Authorization Server that issues tokens for this resource. */
1503
1521
  authorizationServerUrl?: string;
1522
+ /**
1523
+ * Scopes this MCP server accepts, advertised as `scopes_supported` in the
1524
+ * Protected Resource Metadata document so clients request only what they
1525
+ * need. Unlike `requiredScopes`, nothing is enforced from it.
1526
+ */
1527
+ scopesSupported?: string[];
1504
1528
  /**
1505
1529
  * Expected audience — the resource indicator (RFC 8707) this MCP server
1506
1530
  * identifies as. When set, the verified token's `aud` claim must include at
@@ -1830,4 +1854,4 @@ interface McpRouterOptions {
1830
1854
  */
1831
1855
  declare const createMcpRouter: (server: McpServer$1, options?: McpRouterOptions) => McpRouter;
1832
1856
  //#endregion
1833
- export { ApiCallOptions, CognitoUserPoolConfig, type CreateToolGateOptions, DEFAULT_INSTRUCTIONS_LIMIT, type DeferToolsOptions, type DefineToolParams, type GateToolParams, InMemoryServerEventBus, type JsonObjectSchema, McpAuthOptions, McpRouter, McpRouterOptions, McpServer, type McpSurfaceBudget, type McpSurfaceReport, type McpSurfaceTool, type McpSurfaceViolation, type RegisterAppResourceParams, type RegisterToolsParams, type RegisteredAppResource, type ServerEvent, type ServerEventBus, type ServerNotifier, type Tool, type ToolCallContext, type ToolCallGate, type ToolGate, type ToolIdentity, type ToolMetaParams, type ToolSchema, type ToolSearchArgs, UI_EXTENSION_ID, UI_RESOURCE_MIME_TYPE, type UiResourceCsp, type UiResourceMeta, type UiResourcePermissions, type UiToolVisibility, apiCall, checkMcpSurface, checkScopes, createMcpRouter, createToolGate, defineTool, errorBodyMessage, findUnknownToolMentions, getApiHeaders, getIdentity, getRequestLocale, measureMcpSurface, rankTools, registerAppResource, registerTools, z };
1857
+ export { ApiCallOptions, CognitoUserPoolConfig, type CreateToolGateOptions, DEFAULT_DESCRIPTION_LIMIT, DEFAULT_INSTRUCTIONS_LIMIT, type DeferToolsOptions, type DefineToolParams, type GateToolParams, InMemoryServerEventBus, type JsonObjectSchema, McpAuthOptions, McpRouter, McpRouterOptions, McpServer, type McpSurfaceBudget, type McpSurfaceReport, type McpSurfaceTool, type McpSurfaceViolation, type RegisterAppResourceParams, type RegisterToolsParams, type RegisteredAppResource, type ServerEvent, type ServerEventBus, type ServerNotifier, type Tool, type ToolCallContext, type ToolCallGate, type ToolGate, type ToolIdentity, type ToolMetaParams, type ToolSchema, type ToolSearchArgs, UI_EXTENSION_ID, UI_RESOURCE_MIME_TYPE, type UiResourceCsp, type UiResourceMeta, type UiResourcePermissions, type UiToolVisibility, apiCall, checkMcpSurface, checkScopes, createMcpRouter, createToolGate, defineTool, errorBodyMessage, findUnknownToolMentions, getApiHeaders, getIdentity, getRequestLocale, measureMcpSurface, rankTools, registerAppResource, registerTools, z };
package/dist/index.mjs CHANGED
@@ -212,11 +212,17 @@ var createMcpRequestServer = ({
212
212
  //#endregion
213
213
  //#region src/mcpSurface.ts
214
214
  /**
215
- * Claude Code keeps about this many characters of a server's instructions and
216
- * drops the rest without telling anyone, so a rule past it never reaches an
217
- * agent.
215
+ * Claude Code truncates a server's instructions at this many characters
216
+ * without telling anyone, so a rule past it never reaches an agent
217
+ * (https://code.claude.com/docs/en/mcp; a user can change it with
218
+ * `CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH`).
218
219
  */
219
220
  var DEFAULT_INSTRUCTIONS_LIMIT = 2048;
221
+ /**
222
+ * Claude Code truncates each tool description at the same length as the
223
+ * instructions, from the same documentation, and just as silently.
224
+ */
225
+ var DEFAULT_DESCRIPTION_LIMIT = 2048;
220
226
  var sizeOf = tool => {
221
227
  return JSON.stringify({
222
228
  name: tool.name,
@@ -251,6 +257,20 @@ var measureMcpSurface = ({
251
257
  instructions: instructions?.length ?? 0
252
258
  };
253
259
  };
260
+ var checkDescriptions = ({
261
+ tools,
262
+ limit
263
+ }) => {
264
+ return tools.flatMap(tool => {
265
+ const size = tool.description?.length ?? 0;
266
+ return size > limit ? [{
267
+ kind: "description",
268
+ name: tool.name,
269
+ size,
270
+ limit
271
+ }] : [];
272
+ });
273
+ };
254
274
  /**
255
275
  * Every limit an MCP surface exceeds, or `[]` when it fits.
256
276
  *
@@ -295,6 +315,10 @@ var checkMcpSurface = ({
295
315
  limit: budget.perTool
296
316
  });
297
317
  }
318
+ violations.push(...checkDescriptions({
319
+ tools,
320
+ limit: budget.description ?? 2048
321
+ }));
298
322
  const instructionsLimit = budget.instructions ?? 2048;
299
323
  if (report.instructions > instructionsLimit) violations.push({
300
324
  kind: "instructions",
@@ -1589,7 +1613,8 @@ var createMcpRouter = (server, options = {}) => {
1589
1613
  const metadata = resourceUrl !== void 0 && auth.authorizationServerUrl !== void 0 ? {
1590
1614
  document: protectedResourceMetadataDocument({
1591
1615
  resource: resourceUrl,
1592
- authorizationServers: [auth.authorizationServerUrl]
1616
+ authorizationServers: [auth.authorizationServerUrl],
1617
+ scopesSupported: auth.scopesSupported
1593
1618
  }),
1594
1619
  paths: protectedResourceMetadataPaths({
1595
1620
  resource: resourceUrl
@@ -1686,4 +1711,4 @@ var createMcpRouter = (server, options = {}) => {
1686
1711
  };
1687
1712
 
1688
1713
  //#endregion
1689
- export { DEFAULT_INSTRUCTIONS_LIMIT, InMemoryServerEventBus, McpServer, UI_EXTENSION_ID, UI_RESOURCE_MIME_TYPE, apiCall, checkMcpSurface, checkScopes, createMcpRouter, createToolGate, defineTool, errorBodyMessage, findUnknownToolMentions, getApiHeaders, getIdentity, getRequestLocale, measureMcpSurface, rankTools, registerAppResource, registerTools, z };
1714
+ export { DEFAULT_DESCRIPTION_LIMIT, DEFAULT_INSTRUCTIONS_LIMIT, InMemoryServerEventBus, McpServer, UI_EXTENSION_ID, UI_RESOURCE_MIME_TYPE, apiCall, checkMcpSurface, checkScopes, createMcpRouter, createToolGate, defineTool, errorBodyMessage, findUnknownToolMentions, getApiHeaders, getIdentity, getRequestLocale, measureMcpSurface, rankTools, registerAppResource, registerTools, z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/http-server-mcp",
3
- "version": "0.35.0",
3
+ "version": "0.37.0",
4
4
  "description": "Model Context Protocol (MCP) server integration for @ttoss/http-server",
5
5
  "keywords": [
6
6
  "ai",
@@ -37,10 +37,10 @@
37
37
  "@modelcontextprotocol/node": "^2.0.0",
38
38
  "@modelcontextprotocol/server": "^2.0.0",
39
39
  "zod": "^4.4.3",
40
- "@ttoss/auth-core": "^0.17.2",
41
- "@ttoss/http-server": "^0.13.0",
40
+ "@ttoss/http-server-auth": "^0.9.0",
42
41
  "@ttoss/i18n-core": "^0.8.1",
43
- "@ttoss/http-server-auth": "^0.8.5"
42
+ "@ttoss/auth-core": "^0.18.0",
43
+ "@ttoss/http-server": "^0.13.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@modelcontextprotocol/client": "^2.0.0",