@lostgradient/mcp 0.2.6 → 0.3.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.
Files changed (123) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +15 -173
  3. package/dist/http.d.ts +35 -0
  4. package/dist/http.js +251 -0
  5. package/dist/internal/cryptography/encryption.d.ts +108 -0
  6. package/dist/internal/cryptography/encryption.js +241 -0
  7. package/dist/internal/cryptography/hash.d.ts +72 -0
  8. package/dist/internal/cryptography/hash.js +233 -0
  9. package/dist/internal/cryptography/index.d.ts +4 -0
  10. package/dist/internal/cryptography/index.js +2 -0
  11. package/dist/oauth/canonicalize-ip-address.d.ts +0 -6
  12. package/dist/oauth/canonicalize-ip-address.js +113 -0
  13. package/dist/oauth/client-metadata-documents.d.ts +2 -22
  14. package/dist/oauth/client-metadata-documents.js +205 -19
  15. package/dist/oauth/index.d.ts +9 -213
  16. package/dist/oauth/index.js +6 -69
  17. package/dist/oauth/issuer.d.ts +103 -0
  18. package/dist/oauth/issuer.js +564 -0
  19. package/dist/oauth/postgres.d.ts +12 -0
  20. package/dist/oauth/postgres.js +76 -0
  21. package/dist/oauth/safe-public-https-fetch.d.ts +3 -5
  22. package/dist/oauth/safe-public-https-fetch.js +114 -0
  23. package/dist/oauth/security-utilities.d.ts +0 -3
  24. package/dist/oauth/security-utilities.js +93 -0
  25. package/dist/oauth-store.d.ts +108 -0
  26. package/dist/oauth-store.js +321 -0
  27. package/package.json +50 -124
  28. package/dist/chunk-3ek3knfm.js +0 -73
  29. package/dist/chunk-3rr24vhh.js +0 -28
  30. package/dist/chunk-5444sx3n.js +0 -916
  31. package/dist/chunk-6ekjtvcq.js +0 -273
  32. package/dist/chunk-k6fm3cmk.js +0 -132
  33. package/dist/chunk-r9atew6b.js +0 -449
  34. package/dist/chunk-rxnyn7tf.js +0 -19
  35. package/dist/chunk-taxyscge.js +0 -67
  36. package/dist/chunk-tkn6m6az.js +0 -1107
  37. package/dist/chunk-xcf742mf.js +0 -14
  38. package/dist/chunk-zrrf78wj.js +0 -4
  39. package/dist/conformance-fixture-registration.d.ts +0 -30
  40. package/dist/conformance-server.d.ts +0 -1
  41. package/dist/conformance.d.ts +0 -43
  42. package/dist/env.d.ts +0 -59
  43. package/dist/env.js +0 -9
  44. package/dist/environment-schema.d.ts +0 -29
  45. package/dist/environment-schema.js +0 -6
  46. package/dist/golden-prompts.d.ts +0 -42
  47. package/dist/handler-context.d.ts +0 -16
  48. package/dist/http/authenticate.d.ts +0 -35
  49. package/dist/http/authorization-header.d.ts +0 -5
  50. package/dist/http/grant-revocation-channel.d.ts +0 -24
  51. package/dist/http/handler.d.ts +0 -32
  52. package/dist/http/index.d.ts +0 -27
  53. package/dist/http/index.js +0 -870
  54. package/dist/http/listen-inspection.d.ts +0 -11
  55. package/dist/http/request-context.d.ts +0 -17
  56. package/dist/http/responses.d.ts +0 -13
  57. package/dist/http/serving-layer.d.ts +0 -25
  58. package/dist/http/user-handler-cache.d.ts +0 -37
  59. package/dist/http/user-server-event-bus.d.ts +0 -35
  60. package/dist/index.d.ts +0 -29
  61. package/dist/index.js +0 -616
  62. package/dist/localhost-request-validation.d.ts +0 -2
  63. package/dist/logger.d.ts +0 -59
  64. package/dist/logger.js +0 -18
  65. package/dist/long-running-operation-support.d.ts +0 -34
  66. package/dist/metrics.d.ts +0 -64
  67. package/dist/metrics.js +0 -6
  68. package/dist/oauth/authorize-endpoint.d.ts +0 -5
  69. package/dist/oauth/client-authentication.d.ts +0 -10
  70. package/dist/oauth/discovery-metadata.d.ts +0 -19
  71. package/dist/oauth/endpoint-rate-limits.d.ts +0 -10
  72. package/dist/oauth/endpoint-responses.d.ts +0 -10
  73. package/dist/oauth/network-identity.d.ts +0 -32
  74. package/dist/oauth/pkce-validation.d.ts +0 -2
  75. package/dist/oauth/postgres/client-store.d.ts +0 -12
  76. package/dist/oauth/postgres/code-store.d.ts +0 -14
  77. package/dist/oauth/postgres/database.d.ts +0 -59
  78. package/dist/oauth/postgres/index.d.ts +0 -11
  79. package/dist/oauth/postgres/index.js +0 -616
  80. package/dist/oauth/postgres/schema.d.ts +0 -1476
  81. package/dist/oauth/postgres/token-store.d.ts +0 -16
  82. package/dist/oauth/postgres/transaction-store.d.ts +0 -14
  83. package/dist/oauth/redirect-uri-matching.d.ts +0 -2
  84. package/dist/oauth/registration-endpoint.d.ts +0 -2
  85. package/dist/oauth/request-body.d.ts +0 -14
  86. package/dist/oauth/revocation-endpoint.d.ts +0 -2
  87. package/dist/oauth/scope-utilities.d.ts +0 -15
  88. package/dist/oauth/stores.d.ts +0 -225
  89. package/dist/oauth/stores.js +0 -0
  90. package/dist/oauth/testing/contract-fixtures.d.ts +0 -134
  91. package/dist/oauth/testing/index.d.ts +0 -56
  92. package/dist/oauth/testing/index.js +0 -330
  93. package/dist/oauth/token-endpoint.d.ts +0 -2
  94. package/dist/oauth-scope-configuration.d.ts +0 -3
  95. package/dist/prompts/index.d.ts +0 -5
  96. package/dist/prompts/summarize.d.ts +0 -4
  97. package/dist/rate-limit/in-memory-sliding-window-store.d.ts +0 -3
  98. package/dist/rate-limit/index.d.ts +0 -23
  99. package/dist/rate-limit/index.js +0 -29
  100. package/dist/rate-limit/mcp-concurrency-limiter.d.ts +0 -26
  101. package/dist/rate-limit/rate-limit-response.d.ts +0 -1
  102. package/dist/rate-limit/redis-sliding-window-store.d.ts +0 -2
  103. package/dist/rate-limit/request-rate-limiter.d.ts +0 -10
  104. package/dist/rate-limit/sliding-window-rate-limiter.d.ts +0 -16
  105. package/dist/resources/index.d.ts +0 -4
  106. package/dist/resources/user-profile.d.ts +0 -1
  107. package/dist/scope-vocabulary.d.ts +0 -127
  108. package/dist/scopes.d.ts +0 -49
  109. package/dist/server.d.ts +0 -113
  110. package/dist/supported-scopes.d.ts +0 -25
  111. package/dist/sveltekit-mount-state.d.ts +0 -4
  112. package/dist/sveltekit-mount.d.ts +0 -43
  113. package/dist/sveltekit-mount.js +0 -344
  114. package/dist/template-registry.d.ts +0 -16
  115. package/dist/tool-response.d.ts +0 -100
  116. package/dist/tools/get-user-profile.d.ts +0 -8
  117. package/dist/tools/index.d.ts +0 -16
  118. package/dist/tools/list-audit-events.d.ts +0 -11
  119. package/dist/type-assertions.d.ts +0 -1
  120. package/dist/types/primitives.d.ts +0 -130
  121. package/dist/ui-extension-support.d.ts +0 -20
  122. package/dist/version.d.ts +0 -23
  123. package/dist/version.js +0 -6
@@ -1,16 +0,0 @@
1
- import type { z } from 'zod';
2
- import type { McpToolDefinition } from '../types/primitives.js';
3
- import type { McpScope } from '../scopes.js';
4
- export { getUserProfileTool } from './get-user-profile.js';
5
- export { listAuditEventsTool } from './list-audit-events.js';
6
- /**
7
- * The widest legal element type for a heterogeneous registry, pinned to this
8
- * repository's own vocabulary. The schema parameters stay at their defaults
9
- * for the reason the `McpToolDefinition` comment gives — the handler is a
10
- * method shorthand, so parameter checking is bivariant and a concretely
11
- * typed tool can live in this array without widening its own handler by
12
- * hand.
13
- */
14
- type TemplateTool = McpToolDefinition<z.ZodType, z.ZodType | undefined, McpScope>;
15
- export declare const allTools: TemplateTool[];
16
- export declare const conformanceOnlyTools: TemplateTool[];
@@ -1,11 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const listAuditEventsTool: import("../index.js").McpToolDefinition<z.ZodObject<{
3
- cursor: z.ZodOptional<z.ZodString>;
4
- page_size: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
5
- }, z.core.$strip>, z.ZodObject<{
6
- items: z.ZodArray<z.ZodObject<{
7
- identifier: z.ZodString;
8
- message: z.ZodString;
9
- }, z.core.$strip>>;
10
- next_cursor: z.ZodNullable<z.ZodString>;
11
- }, z.core.$strip>, "profile:read" | "audit:read" | "prompts:read">;
@@ -1 +0,0 @@
1
- export {};
@@ -1,130 +0,0 @@
1
- import type { z } from 'zod';
2
- import type { CallToolResult, GetPromptResult, ReadResourceResult } from '@modelcontextprotocol/server';
3
- export type McpUserProfile = {
4
- id: string;
5
- email: string;
6
- name: string;
7
- image: string | null;
8
- role: string;
9
- };
10
- export type McpContext = {
11
- userId: string;
12
- user: McpUserProfile;
13
- /**
14
- * OBS-001: the same request identifier `application.ts` generated at
15
- * the HTTP boundary (`X-Request-Id`), carried through OAuth token
16
- * validation (`McpRequestAuthExtra.requestId`) into every tool,
17
- * resource, and prompt handler. Lets one connector action be traced end
18
- * to end through logs without correlating on anything secret (a bearer
19
- * token, a session cookie). Optional because standalone test contexts
20
- * (`createTestContext`) have no real HTTP request to derive one from.
21
- */
22
- requestId?: string;
23
- /**
24
- * PROTO-002: the SDK's own per-request `AbortSignal`
25
- * (`ctx.mcpReq.signal`), threaded through so a handler that awaits a
26
- * cancellable operation (e.g. `runWithStandardizedTimeout` from
27
- * `long-running-operation-support.ts`) can pass it straight through and
28
- * genuinely stop work when the caller disconnects or sends
29
- * `notifications/cancelled` — not just abandon a wrapper promise.
30
- */
31
- signal: AbortSignal;
32
- /**
33
- * PROTO-002 / S-11: publishes a `notifications/resources/updated` event
34
- * for `uri`, scoped to only the authenticated user this context was
35
- * built for (see the HTTP package's per-user event bus).
36
- * Undefined when no event bus is wired for this request (e.g. a
37
- * standalone test context) — nothing to publish to in that case.
38
- */
39
- publishResourceUpdate?: (uri: string) => Promise<void>;
40
- };
41
- /**
42
- * META-001: the four tool-safety hints the `2026-07-28` era gives real
43
- * weight to. All four are required (not optional) so a tool definition
44
- * that omits one is a compile-time error, not a silent gap a reviewer has
45
- * to notice by hand.
46
- */
47
- export type McpToolAnnotations = {
48
- /** The tool only reads data; it never mutates state. */
49
- readOnlyHint: boolean;
50
- /** Calling the tool can cause irreversible or destructive effects. */
51
- destructiveHint: boolean;
52
- /** Calling the tool twice with the same input has no additional effect. */
53
- idempotentHint: boolean;
54
- /** The tool interacts with an open-ended external world, not a fixed set of resources. */
55
- openWorldHint: boolean;
56
- };
57
- /**
58
- * META-001: `title`, `description`, and `annotations` are required (not
59
- * optional), which is what turns "forgot to add metadata" into a
60
- * `tsc` failure on the tool's own file instead of a silent gap discovered
61
- * later against a live connector. `outputSchema` stays optional — a tool
62
- * with no structured result genuinely has none to declare — but when it
63
- * is present the handler's return type is checked against it, so a
64
- * mismatched `structuredContent` is also a compile-time error.
65
- *
66
- * `InputSchema`/`OutputSchema` default to the widest legal type so
67
- * `McpToolDefinition` (no type arguments) can still be used as the
68
- * element type of a heterogeneous `allTools` array; individual tool
69
- * files should let `defineTool` infer their concrete schema types instead
70
- * of writing the type arguments out by hand.
71
- */
72
- export type McpToolDefinition<InputSchema extends z.ZodType = z.ZodType, OutputSchema extends z.ZodType | undefined = z.ZodType | undefined, Scope extends string = string> = {
73
- name: string;
74
- title: string;
75
- description: string;
76
- inputSchema: InputSchema;
77
- outputSchema?: OutputSchema;
78
- annotations: McpToolAnnotations;
79
- /**
80
- * AUTHZ-001: the single OAuth scope a caller's access token must carry to
81
- * invoke this tool, checked before `handler` runs (never before —
82
- * `tools/list` is unaffected, so a client can still see a tool it does
83
- * not currently have the scope to call). Required, not optional: an
84
- * operation with no meaningfully distinct access requirement still
85
- * declares the scope that best describes what it does, rather than the
86
- * type system silently allowing "no scope check" to mean "public."
87
- */
88
- requiredScope: Scope;
89
- /** MCP Apps UI metadata (`_meta.ui.resourceUri`, `_meta.ui.visibility`). See the package `CLAUDE.md`. */
90
- _meta?: Record<string, unknown>;
91
- handler(input: z.infer<InputSchema>, context: McpContext): Promise<OutputSchema extends z.ZodType ? // The SDK only validates `structuredContent` against `outputSchema`
92
- CallToolResult & {
93
- structuredContent?: z.infer<OutputSchema>;
94
- } : CallToolResult>;
95
- };
96
- /**
97
- * Identity helper that exists only for inference: writing
98
- * `export const fooTool = defineTool({ ... })` lets TypeScript infer
99
- * `InputSchema`/`OutputSchema` from the literal `inputSchema`/`outputSchema`
100
- * values instead of the author spelling out `McpToolDefinition<X, Y>` by
101
- * hand on every tool.
102
- */
103
- export declare function defineTool<InputSchema extends z.ZodType, OutputSchema extends z.ZodType | undefined = undefined, Scope extends string = string>(definition: McpToolDefinition<InputSchema, OutputSchema, Scope>): McpToolDefinition<InputSchema, OutputSchema, Scope>;
104
- export type McpResourceDefinition<Scope extends string = string> = {
105
- name: string;
106
- title: string;
107
- uri: string;
108
- description: string;
109
- mimeType: string;
110
- /** AUTHZ-001: see `McpToolDefinition.requiredScope` — same contract, checked before `resources/read` reaches `handler`. */
111
- requiredScope: Scope;
112
- handler(uri: URL, context: McpContext): Promise<ReadResourceResult>;
113
- };
114
- /**
115
- * Identity helper matching `defineTool`, so a resource can be written
116
- * against a vocabulary-bound definer rather than a bare type annotation.
117
- */
118
- export declare function defineResource<Scope extends string = string>(definition: McpResourceDefinition<Scope>): McpResourceDefinition<Scope>;
119
- export type McpPromptDefinition<Arguments extends Record<string, z.ZodType> | undefined = Record<string, z.ZodType> | undefined, Scope extends string = string> = {
120
- name: string;
121
- title: string;
122
- description: string;
123
- arguments: Arguments;
124
- /** AUTHZ-001: see `McpToolDefinition.requiredScope` — same contract, checked before `prompts/get` reaches `handler`. */
125
- requiredScope: Scope;
126
- handler(arguments_: Arguments extends Record<string, z.ZodType> ? {
127
- [Key in keyof Arguments]: z.infer<Arguments[Key]>;
128
- } : Record<string, never>, context: McpContext): Promise<GetPromptResult>;
129
- };
130
- export declare function definePrompt<Arguments extends Record<string, z.ZodType> | undefined, Scope extends string = string>(definition: McpPromptDefinition<Arguments, Scope>): McpPromptDefinition<Arguments, Scope>;
@@ -1,20 +0,0 @@
1
- import type { McpRegistry } from './scope-vocabulary.js';
2
- /**
3
- * CONTENT-001 / review finding: advertising the MCP Apps UI extension is
4
- * not just gated on the `MCP_ENABLE_UI_EXTENSION` flag (which defaults off,
5
- * but an operator -- or this repository's own setup wizard -- can still
6
- * turn it on) -- it also requires at least one registered resource that is
7
- * actually an MCP App (`RESOURCE_MIME_TYPE`). `packages/mcp-apps` ships no
8
- * application today, so this predicate is always `false` in this
9
- * repository, mechanically keeping the capability advertised as absent
10
- * even if the flag is turned on by mistake.
11
- *
12
- * This is the single source of truth for that predicate. `server.ts`'s
13
- * real `/mcp` capabilities and the OAuth discovery metadata handler both
14
- * call this function rather than each
15
- * re-deriving their own copy of it, so a client can never discover UI
16
- * extension support in OAuth metadata and then receive server capabilities
17
- * without it (or vice versa) -- the two advertisements are mechanically
18
- * kept in agreement, not just conventionally.
19
- */
20
- export declare function hasRegisteredUiExtensionResource(registry: McpRegistry): boolean;
package/dist/version.d.ts DELETED
@@ -1,23 +0,0 @@
1
- /**
2
- * The version this server advertises over the wire.
3
- *
4
- * A checked-in constant rather than a read of `package.json`, for two
5
- * reasons that pull in the same direction:
6
- *
7
- * - A plain string literal survives every bundler by construction. The
8
- * alternative a consumer would otherwise inherit —
9
- * `createRequire(import.meta.url)('../package.json')` — resolves
10
- * relative to the *generated bundle* rather than to this source file,
11
- * so a host that bundles this package advertises the host's version, or
12
- * fails outright for a nested output chunk.
13
- * - It reads nothing at runtime, so it cannot be the reason importing this
14
- * package touches the filesystem.
15
- *
16
- * The obvious cost of a duplicated literal is drift, and that is exactly
17
- * what `version.test.ts` removes: it asserts this constant equals
18
- * `package.json`'s `version`, so bumping one without the other is a red
19
- * test rather than a wrong number on the wire. That test is the only
20
- * thing making this approach safe — do not delete it to silence a release
21
- * bump; update this constant instead.
22
- */
23
- export declare const PACKAGE_VERSION = "0.2.6";
package/dist/version.js DELETED
@@ -1,6 +0,0 @@
1
- import {
2
- PACKAGE_VERSION
3
- } from "./chunk-zrrf78wj.js";
4
- export {
5
- PACKAGE_VERSION
6
- };