@dapplelight/signet-server 0.0.0-stage → 0.3.1
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 +799 -2
- package/dist/analytics/engine.d.ts +35 -0
- package/dist/analytics/engine.d.ts.map +1 -0
- package/dist/analytics/engine.js +65 -0
- package/dist/analytics/engine.js.map +1 -0
- package/dist/analytics/index.d.ts +3 -0
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/index.js +3 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics/ingest.d.ts +16 -0
- package/dist/analytics/ingest.d.ts.map +1 -0
- package/dist/analytics/ingest.js +37 -0
- package/dist/analytics/ingest.js.map +1 -0
- package/dist/auth/bearer.d.ts +9 -0
- package/dist/auth/bearer.d.ts.map +1 -0
- package/dist/auth/bearer.js +31 -0
- package/dist/auth/bearer.js.map +1 -0
- package/dist/auth/better-auth.d.ts +65 -0
- package/dist/auth/better-auth.d.ts.map +1 -0
- package/dist/auth/better-auth.js +44 -0
- package/dist/auth/better-auth.js.map +1 -0
- package/dist/auth/guards.d.ts +10 -0
- package/dist/auth/guards.d.ts.map +1 -0
- package/dist/auth/guards.js +26 -0
- package/dist/auth/guards.js.map +1 -0
- package/dist/auth/hono.d.ts +13 -0
- package/dist/auth/hono.d.ts.map +1 -0
- package/dist/auth/hono.js +44 -0
- package/dist/auth/hono.js.map +1 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +6 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/passcode.d.ts +3 -0
- package/dist/auth/passcode.d.ts.map +1 -0
- package/dist/auth/passcode.js +36 -0
- package/dist/auth/passcode.js.map +1 -0
- package/dist/auth/session.d.ts +20 -0
- package/dist/auth/session.d.ts.map +1 -0
- package/dist/auth/session.js +92 -0
- package/dist/auth/session.js.map +1 -0
- package/dist/doctor/check.d.ts +36 -0
- package/dist/doctor/check.d.ts.map +1 -0
- package/dist/doctor/check.js +167 -0
- package/dist/doctor/check.js.map +1 -0
- package/dist/doctor/cli.d.ts +3 -0
- package/dist/doctor/cli.d.ts.map +1 -0
- package/dist/doctor/cli.js +45 -0
- package/dist/doctor/cli.js.map +1 -0
- package/dist/env/index.d.ts +3 -0
- package/dist/env/index.d.ts.map +1 -0
- package/dist/env/index.js +3 -0
- package/dist/env/index.js.map +1 -0
- package/dist/env/runtime.d.ts +4 -0
- package/dist/env/runtime.d.ts.map +1 -0
- package/dist/env/runtime.js +14 -0
- package/dist/env/runtime.js.map +1 -0
- package/dist/env/schema.d.ts +8 -0
- package/dist/env/schema.d.ts.map +1 -0
- package/dist/env/schema.js +48 -0
- package/dist/env/schema.js.map +1 -0
- package/dist/http/errors.d.ts +27 -0
- package/dist/http/errors.d.ts.map +1 -0
- package/dist/http/errors.js +50 -0
- package/dist/http/errors.js.map +1 -0
- package/dist/http/index.d.ts +3 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +3 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/status-codes.d.ts +2 -0
- package/dist/http/status-codes.d.ts.map +1 -0
- package/dist/http/status-codes.js +13 -0
- package/dist/http/status-codes.js.map +1 -0
- package/dist/http/validate.d.ts +6 -0
- package/dist/http/validate.d.ts.map +1 -0
- package/dist/http/validate.js +42 -0
- package/dist/http/validate.js.map +1 -0
- package/dist/mcp/errors.d.ts +40 -0
- package/dist/mcp/errors.d.ts.map +1 -0
- package/dist/mcp/errors.js +69 -0
- package/dist/mcp/errors.js.map +1 -0
- package/dist/mcp/hono.d.ts +15 -0
- package/dist/mcp/hono.d.ts.map +1 -0
- package/dist/mcp/hono.js +22 -0
- package/dist/mcp/hono.js.map +1 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +4 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/interaction.d.ts +18 -0
- package/dist/mcp/interaction.d.ts.map +1 -0
- package/dist/mcp/interaction.js +75 -0
- package/dist/mcp/interaction.js.map +1 -0
- package/dist/mcp/primitives.d.ts +84 -0
- package/dist/mcp/primitives.d.ts.map +1 -0
- package/dist/mcp/primitives.js +174 -0
- package/dist/mcp/primitives.js.map +1 -0
- package/dist/mcp/server.d.ts +88 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +139 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/middleware/cors.d.ts +8 -0
- package/dist/middleware/cors.d.ts.map +1 -0
- package/dist/middleware/cors.js +19 -0
- package/dist/middleware/cors.js.map +1 -0
- package/dist/middleware/index.d.ts +5 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +5 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/rate-limit-do.d.ts +23 -0
- package/dist/middleware/rate-limit-do.d.ts.map +1 -0
- package/dist/middleware/rate-limit-do.js +41 -0
- package/dist/middleware/rate-limit-do.js.map +1 -0
- package/dist/middleware/rate-limit.d.ts +23 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/middleware/rate-limit.js +65 -0
- package/dist/middleware/rate-limit.js.map +1 -0
- package/dist/middleware/request-id.d.ts +8 -0
- package/dist/middleware/request-id.d.ts.map +1 -0
- package/dist/middleware/request-id.js +16 -0
- package/dist/middleware/request-id.js.map +1 -0
- package/dist/middleware/secure-headers.d.ts +11 -0
- package/dist/middleware/secure-headers.d.ts.map +1 -0
- package/dist/middleware/secure-headers.js +31 -0
- package/dist/middleware/secure-headers.js.map +1 -0
- package/dist/notify/email.d.ts +17 -0
- package/dist/notify/email.d.ts.map +1 -0
- package/dist/notify/email.js +46 -0
- package/dist/notify/email.js.map +1 -0
- package/dist/notify/index.d.ts +4 -0
- package/dist/notify/index.d.ts.map +1 -0
- package/dist/notify/index.js +4 -0
- package/dist/notify/index.js.map +1 -0
- package/dist/notify/push.d.ts +24 -0
- package/dist/notify/push.d.ts.map +1 -0
- package/dist/notify/push.js +29 -0
- package/dist/notify/push.js.map +1 -0
- package/dist/notify/telegram.d.ts +10 -0
- package/dist/notify/telegram.d.ts.map +1 -0
- package/dist/notify/telegram.js +35 -0
- package/dist/notify/telegram.js.map +1 -0
- package/dist/oauth-rs/hono.d.ts +13 -0
- package/dist/oauth-rs/hono.d.ts.map +1 -0
- package/dist/oauth-rs/hono.js +56 -0
- package/dist/oauth-rs/hono.js.map +1 -0
- package/dist/oauth-rs/index.d.ts +4 -0
- package/dist/oauth-rs/index.d.ts.map +1 -0
- package/dist/oauth-rs/index.js +4 -0
- package/dist/oauth-rs/index.js.map +1 -0
- package/dist/oauth-rs/jwks.d.ts +33 -0
- package/dist/oauth-rs/jwks.d.ts.map +1 -0
- package/dist/oauth-rs/jwks.js +105 -0
- package/dist/oauth-rs/jwks.js.map +1 -0
- package/dist/oauth-rs/metadata.d.ts +22 -0
- package/dist/oauth-rs/metadata.d.ts.map +1 -0
- package/dist/oauth-rs/metadata.js +20 -0
- package/dist/oauth-rs/metadata.js.map +1 -0
- package/dist/oauth-rs/verify.d.ts +39 -0
- package/dist/oauth-rs/verify.d.ts.map +1 -0
- package/dist/oauth-rs/verify.js +111 -0
- package/dist/oauth-rs/verify.js.map +1 -0
- package/dist/observability/logger.d.ts +40 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +167 -0
- package/dist/observability/logger.js.map +1 -0
- package/dist/observability/sentry.d.ts +32 -0
- package/dist/observability/sentry.d.ts.map +1 -0
- package/dist/observability/sentry.js +76 -0
- package/dist/observability/sentry.js.map +1 -0
- package/package.json +204 -4
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export declare function parseBody<T>(c: Context, schema: z.ZodType<T>): Promise<T>;
|
|
4
|
+
export declare function parseQuery<T>(c: Context, schema: z.ZodType<T>): T;
|
|
5
|
+
export declare function parseParams<T>(c: Context, schema: z.ZodType<T>): T;
|
|
6
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/http/validate.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAkB5B,wBAAsB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAU/E;AAGD,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAOjE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAIlE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ApiException } from "./errors.js";
|
|
2
|
+
function fail(result) {
|
|
3
|
+
const formErrors = [];
|
|
4
|
+
const fieldErrors = {};
|
|
5
|
+
for (const issue of result.error.issues) {
|
|
6
|
+
const key = issue.path[0];
|
|
7
|
+
if (key === undefined)
|
|
8
|
+
formErrors.push(issue.message);
|
|
9
|
+
else {
|
|
10
|
+
const k = String(key);
|
|
11
|
+
fieldErrors[k] = [...(fieldErrors[k] ?? []), issue.message];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
throw new ApiException(400, "Validation failed", "VALIDATION_FAILED", { formErrors, fieldErrors });
|
|
15
|
+
}
|
|
16
|
+
export async function parseBody(c, schema) {
|
|
17
|
+
let body;
|
|
18
|
+
try {
|
|
19
|
+
body = await c.req.json();
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
throw new ApiException(400, "Invalid JSON body", "INVALID_JSON");
|
|
23
|
+
}
|
|
24
|
+
const result = schema.safeParse(body);
|
|
25
|
+
if (!result.success)
|
|
26
|
+
fail(result);
|
|
27
|
+
return result.data;
|
|
28
|
+
}
|
|
29
|
+
export function parseQuery(c, schema) {
|
|
30
|
+
const query = Object.fromEntries(Object.entries(c.req.queries()).map(([k, v]) => [k, v.length === 1 ? v[0] : v]));
|
|
31
|
+
const result = schema.safeParse(query);
|
|
32
|
+
if (!result.success)
|
|
33
|
+
fail(result);
|
|
34
|
+
return result.data;
|
|
35
|
+
}
|
|
36
|
+
export function parseParams(c, schema) {
|
|
37
|
+
const result = schema.safeParse(c.req.param());
|
|
38
|
+
if (!result.success)
|
|
39
|
+
fail(result);
|
|
40
|
+
return result.data;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/http/validate.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,SAAS,IAAI,CAAC,MAA6B;IACzC,MAAM,UAAU,GAAa,EAAE,CAAA;IAC/B,MAAM,WAAW,GAA6B,EAAE,CAAA;IAChD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QACxC,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACzB,IAAI,GAAG,KAAK,SAAS;YAAE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;aAChD,CAAC;YACJ,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;YACrB,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;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D,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAA;IAC9C,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,MAAM,CAAC,IAAI,CAAA;AACpB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
import type { CallToolResult } from "./server.js";
|
|
3
|
+
export type ErrorMeta = {
|
|
4
|
+
tool: string;
|
|
5
|
+
kind?: "resource" | "prompt";
|
|
6
|
+
};
|
|
7
|
+
export type ToolErrorInfo = {
|
|
8
|
+
code: string;
|
|
9
|
+
message: string;
|
|
10
|
+
details?: {
|
|
11
|
+
formErrors: string[];
|
|
12
|
+
fieldErrors: Record<string, string[]>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export type ToolErrorOptions = {
|
|
16
|
+
errorResult?: (err: unknown, meta: {
|
|
17
|
+
tool: string;
|
|
18
|
+
}) => CallToolResult | undefined;
|
|
19
|
+
mapError?: (err: unknown) => ToolErrorInfo | undefined;
|
|
20
|
+
onError?: (err: unknown, meta: ErrorMeta) => void | Promise<unknown>;
|
|
21
|
+
};
|
|
22
|
+
type ZodErrorLike = Error & {
|
|
23
|
+
issues: Array<{
|
|
24
|
+
path: ReadonlyArray<PropertyKey>;
|
|
25
|
+
message: string;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
export declare function isZodError(err: unknown): err is ZodErrorLike;
|
|
29
|
+
type HttpExceptionLike = Error & {
|
|
30
|
+
status: number;
|
|
31
|
+
code?: unknown;
|
|
32
|
+
details?: ToolErrorInfo["details"];
|
|
33
|
+
};
|
|
34
|
+
export declare function isHttpException(err: unknown): err is HttpExceptionLike;
|
|
35
|
+
export declare function describeToolError(err: unknown): ToolErrorInfo | undefined;
|
|
36
|
+
export declare function toolErrorResult(info: ToolErrorInfo): CallToolResult;
|
|
37
|
+
export declare const INTERNAL_ERROR: ToolErrorInfo;
|
|
38
|
+
export declare function report(opts: ToolErrorOptions, err: unknown, meta: ErrorMeta, c: Context | undefined): void;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/mcp/errors.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAMjD,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAA;CAAE,CAAA;AAGtE,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;CAC1E,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAc7B,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,cAAc,GAAG,SAAS,CAAA;IAKlF,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,aAAa,GAAG,SAAS,CAAA;IAKtD,OAAO,CAAC,EAAE,CACR,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,SAAS,KAEZ,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC7B,CAAA;AAED,KAAK,YAAY,GAAG,KAAK,GAAG;IAC1B,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACrE,CAAA;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,YAAY,CAK5D;AAED,KAAK,iBAAiB,GAAG,KAAK,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;CACnC,CAAA;AAMD,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,iBAAiB,CAOtE;AAmBD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAgBzE;AAGD,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,cAAc,CAWnE;AAED,eAAO,MAAM,cAAc,EAAE,aAAqE,CAAA;AAGlG,wBAAgB,MAAM,CACpB,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,SAAS,EACf,CAAC,EAAE,OAAO,GAAG,SAAS,GACrB,IAAI,CAcN"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { STATUS_CODES } from "../http/status-codes.js";
|
|
2
|
+
export function isZodError(err) {
|
|
3
|
+
return (err instanceof Error && err.name === "ZodError" && Array.isArray(err.issues));
|
|
4
|
+
}
|
|
5
|
+
export function isHttpException(err) {
|
|
6
|
+
if (!(err instanceof Error))
|
|
7
|
+
return false;
|
|
8
|
+
const e = err;
|
|
9
|
+
return (typeof e.status === "number" &&
|
|
10
|
+
(e.name === "HTTPException" || typeof e.getResponse === "function"));
|
|
11
|
+
}
|
|
12
|
+
function flatten(err) {
|
|
13
|
+
const formErrors = [];
|
|
14
|
+
const fieldErrors = {};
|
|
15
|
+
for (const issue of err.issues) {
|
|
16
|
+
if (issue.path.length === 0)
|
|
17
|
+
formErrors.push(issue.message);
|
|
18
|
+
else {
|
|
19
|
+
const key = String(issue.path[0]);
|
|
20
|
+
fieldErrors[key] = [...(fieldErrors[key] ?? []), issue.message];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { formErrors, fieldErrors };
|
|
24
|
+
}
|
|
25
|
+
export function describeToolError(err) {
|
|
26
|
+
if (isHttpException(err)) {
|
|
27
|
+
return {
|
|
28
|
+
code: (typeof err.code === "string" ? err.code : undefined) ??
|
|
29
|
+
STATUS_CODES[err.status] ??
|
|
30
|
+
"HTTP_ERROR",
|
|
31
|
+
message: err.message,
|
|
32
|
+
...(err.details ? { details: err.details } : {}),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (isZodError(err)) {
|
|
36
|
+
return { code: "VALIDATION_FAILED", message: "Validation failed", details: flatten(err) };
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
export function toolErrorResult(info) {
|
|
41
|
+
return {
|
|
42
|
+
isError: true,
|
|
43
|
+
content: [{ type: "text", text: `${info.code}: ${info.message}` }],
|
|
44
|
+
structuredContent: {
|
|
45
|
+
success: false,
|
|
46
|
+
error: info.message,
|
|
47
|
+
code: info.code,
|
|
48
|
+
...(info.details ? { details: info.details } : {}),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export const INTERNAL_ERROR = { code: "INTERNAL_ERROR", message: "Internal error" };
|
|
53
|
+
export function report(opts, err, meta, c) {
|
|
54
|
+
let pending;
|
|
55
|
+
try {
|
|
56
|
+
pending = opts.onError?.(err, meta);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!(pending instanceof Promise))
|
|
62
|
+
return;
|
|
63
|
+
const settled = pending.catch(() => { });
|
|
64
|
+
try {
|
|
65
|
+
c?.executionCtx.waitUntil(settled);
|
|
66
|
+
}
|
|
67
|
+
catch { }
|
|
68
|
+
}
|
|
69
|
+
//# sourceMapp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E,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAGlG,MAAM,UAAU,MAAM,CACpB,IAAsB,EACtB,GAAY,EACZ,IAAe,EACf,CAAsB;IAEtB,IAAI,OAAgB,CAAA;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAM;IACR,CAAC;IACD,IAAI,CAAC,CAAC,OAAO,YAAY,OAAO,CAAC;QAAE,OAAM;IACzC,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAGvC,IAAI,CAAC;QACH,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IACpC,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CreateMcpHandlerOptions, type McpRequestContext, type McpServer } from "@modelcontextprotocol/server";
|
|
2
|
+
import type { Context, Handler, Hono, MiddlewareHandler } from "hono";
|
|
3
|
+
import { type CreateMcpServerOptions } from "./server.js";
|
|
4
|
+
export type McpHandlerOptions = (Omit<CreateMcpServerOptions, "context"> | {
|
|
5
|
+
server: (c: Context, req: McpRequestContext) => McpServer | Promise<McpServer>;
|
|
6
|
+
}) & {
|
|
7
|
+
http?: Omit<CreateMcpHandlerOptions, "bus" | "maxSubscriptions" | "responseMode"> & {
|
|
8
|
+
responseMode?: "auto" | "sse";
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare function mcpHandler(options: McpHandlerOptions): Handler;
|
|
12
|
+
export declare function mountMcp(app: Hono<any>, path: string, options: McpHandlerOptions & {
|
|
13
|
+
middleware?: MiddlewareHandler[];
|
|
14
|
+
}): void;
|
|
15
|
+
//# sourceMappingURL=hono.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../src/mcp/hono.ts"],"names":[],"mappings":"AAyBA,OAAO,EACL,KAAK,uBAAuB,EAE5B,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAA;AAErE,OAAO,EAAE,KAAK,sBAAsB,EAAmB,MAAM,aAAa,CAAA;AAE1E,MAAM,MAAM,iBAAiB,GAAG,CAC5B,IAAI,CAAC,sBAAsB,EAAE,SAAS,CAAC,GACvC;IAME,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB,KAAK,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;CAC/E,CACJ,GAAG;IAQF,IAAI,CAAC,EAAE,IAAI,CAAC,uBAAuB,EAAE,KAAK,GAAG,kBAAkB,GAAG,cAAc,CAAC,GAAG;QAClF,YAAY,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;KAC9B,CAAA;CACF,CAAA;AAMD,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAe9D;AAOD,wBAAgB,QAAQ,CAEtB,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,GAAG;IAAE,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAChE,IAAI,CAMN"}
|
package/dist/mcp/hono.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createMcpHandler, } from "@modelcontextprotocol/server";
|
|
2
|
+
import { createMcpServer } from "./server.js";
|
|
3
|
+
export function mcpHandler(options) {
|
|
4
|
+
const { http, ...rest } = options;
|
|
5
|
+
return (c) => {
|
|
6
|
+
const handler = createMcpHandler((req) => "server" in rest
|
|
7
|
+
? rest.server(c, req)
|
|
8
|
+
: createMcpServer({
|
|
9
|
+
...rest,
|
|
10
|
+
context: { c, token: c.get("token") },
|
|
11
|
+
}), http);
|
|
12
|
+
return handler.fetch(c.req.raw);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function mountMcp(app, path, options) {
|
|
16
|
+
const { middleware = [], ...rest } = options;
|
|
17
|
+
const methods = ["GET", "POST", "DELETE"];
|
|
18
|
+
for (const m of middleware)
|
|
19
|
+
app.on(methods, path, m);
|
|
20
|
+
app.on(methods, path, mcpHandler(rest));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=hono.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono.js","sourceRoot":"","sources":["../../src/mcp/hono.ts"],"names":[],"mappings":"AAyBA,OAAO,EAEL,gBAAgB,GAGjB,MAAM,8BAA8B,CAAA;AAGrC,OAAO,EAA+B,eAAe,EAAE,MAAM,aAAa,CAAA;AA6B1E,MAAM,UAAU,UAAU,CAAC,OAA0B;IACnD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;IACjC,OAAO,CAAC,CAAC,EAAE,EAAE;QACX,MAAM,OAAO,GAAG,gBAAgB,CAC9B,CAAC,GAAG,EAAE,EAAE,CACN,QAAQ,IAAI,IAAI;YACd,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC;YACrB,CAAC,CAAC,eAAe,CAAC;gBACd,GAAG,IAAI;gBACP,OAAO,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAA8B,EAAE;aACnE,CAAC,EACR,IAAI,CACL,CAAA;QACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACjC,CAAC,CAAA;AACH,CAAC;AAOD,MAAM,UAAU,QAAQ,CAEtB,GAAc,EACd,IAAY,EACZ,OAAiE;IAEjE,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;IAC5C,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;IAEzC,KAAK,MAAM,CAAC,IAAI,UAAU;QAAE,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACpD,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAyB,CAAC,CAAC,CAAA;AAC9D,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { type ConfirmOptions, type ConfirmPayload, type ConfirmResult, confirm, isConfirmPending, progress, } from "./interaction.js";
|
|
2
|
+
export { definePrompt, defineResource, type ListedResource, type McpPrompt, type McpResource, type PromptContext, type PromptDefinition, type PromptMessageInput, type PromptReturn, type ResourceContext, type ResourceDefinition, type ResourceReturn, resourceResult, } from "./primitives.js";
|
|
3
|
+
export * from "./server.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,OAAO,EACP,gBAAgB,EAChB,QAAQ,GACT,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,OAAO,EACP,gBAAgB,EAChB,QAAQ,GACT,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,YAAY,EACZ,cAAc,EAWd,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { inputRequired } from "@modelcontextprotocol/server";
|
|
2
|
+
import type { ToolContext } from "./server.js";
|
|
3
|
+
export type ConfirmPayload = {
|
|
4
|
+
tool: string;
|
|
5
|
+
id: string;
|
|
6
|
+
fp: string;
|
|
7
|
+
};
|
|
8
|
+
export type ConfirmResult = "confirmed" | "declined" | "unsupported";
|
|
9
|
+
export type ConfirmOptions = {
|
|
10
|
+
message: string;
|
|
11
|
+
detail?: string;
|
|
12
|
+
args?: unknown;
|
|
13
|
+
key?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function confirm(ctx: ToolContext, { message, detail, args, key }: ConfirmOptions): Promise<ConfirmResult | ReturnType<typeof inputRequired>>;
|
|
16
|
+
export declare function isConfirmPending(value: ConfirmResult | ReturnType<typeof inputRequired>): value is ReturnType<typeof inputRequired>;
|
|
17
|
+
export declare function progress(ctx: ToolContext, done: number, total?: number, message?: string): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=interaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../../src/mcp/interaction.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,aAAa,EAAwC,MAAM,8BAA8B,CAAA;AAClG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAK9C,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AASrE,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,aAAa,CAAA;AAEpE,MAAM,MAAM,cAAc,GAAG;IAE3B,OAAO,EAAE,MAAM,CAAA;IAMf,MAAM,CAAC,EAAE,MAAM,CAAA;IASf,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAuDD,wBAAsB,OAAO,CAC3B,GAAG,EAAE,WAAW,EAChB,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,cAAc,GAC7C,OAAO,CAAC,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAgD3D;AAGD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,GACtD,KAAK,IAAI,UAAU,CAAC,OAAO,aAAa,CAAC,CAE3C;AAWD,wBAAsB,QAAQ,CAC5B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { inputRequired, inputResponse, isInputRequiredResult } from "@modelcontextprotocol/server";
|
|
2
|
+
const CONFIRM_KEY = "signet_confirm";
|
|
3
|
+
function canonicalize(value) {
|
|
4
|
+
if (Array.isArray(value))
|
|
5
|
+
return value.map(canonicalize);
|
|
6
|
+
if (value !== null && typeof value === "object") {
|
|
7
|
+
const obj = value;
|
|
8
|
+
return Object.fromEntries(Object.keys(obj)
|
|
9
|
+
.sort()
|
|
10
|
+
.map((k) => [k, canonicalize(obj[k])]));
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
async function fingerprint(args) {
|
|
15
|
+
const bytes = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify(canonicalize(args ?? null))));
|
|
16
|
+
return [...new Uint8Array(bytes)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
17
|
+
}
|
|
18
|
+
export async function confirm(ctx, { message, detail, args, key }) {
|
|
19
|
+
const id = key ?? `${CONFIRM_KEY}:${ctx.tool}`;
|
|
20
|
+
const view = inputResponse(ctx.mcp.mcpReq.inputResponses, id);
|
|
21
|
+
if (view.kind === "missing") {
|
|
22
|
+
if (!ctx.confirmSupport.getClientCapabilities()?.elicitation)
|
|
23
|
+
return "unsupported";
|
|
24
|
+
const payload = { tool: ctx.tool, id, fp: await fingerprint(args) };
|
|
25
|
+
const requestState = await ctx.confirmSupport.mint?.(payload);
|
|
26
|
+
return inputRequired({
|
|
27
|
+
inputRequests: {
|
|
28
|
+
[id]: inputRequired.elicit({
|
|
29
|
+
message: detail ? `${message}\n\n${detail}` : message,
|
|
30
|
+
requestedSchema: {
|
|
31
|
+
type: "object",
|
|
32
|
+
properties: { confirm: { type: "boolean", title: "Confirm" } },
|
|
33
|
+
required: ["confirm"],
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
...(requestState ? { requestState } : {}),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (view.kind !== "elicit" || view.action !== "accept" || view.content?.confirm !== true) {
|
|
41
|
+
return "declined";
|
|
42
|
+
}
|
|
43
|
+
if (ctx.confirmSupport.mint) {
|
|
44
|
+
const state = ctx.mcp.mcpReq.requestState();
|
|
45
|
+
if (!state ||
|
|
46
|
+
state.tool !== ctx.tool ||
|
|
47
|
+
state.id !== id ||
|
|
48
|
+
state.fp !== (await fingerprint(args)))
|
|
49
|
+
return "declined";
|
|
50
|
+
}
|
|
51
|
+
return "confirmed";
|
|
52
|
+
}
|
|
53
|
+
export function isConfirmPending(value) {
|
|
54
|
+
return isInputRequiredResult(value);
|
|
55
|
+
}
|
|
56
|
+
export async function progress(ctx, done, total, message) {
|
|
57
|
+
const token = ctx.mcp.mcpReq._meta
|
|
58
|
+
?.progressToken;
|
|
59
|
+
if (token === undefined)
|
|
60
|
+
return;
|
|
61
|
+
try {
|
|
62
|
+
await ctx.mcp.mcpReq.notify({
|
|
63
|
+
method: "notifications/progress",
|
|
64
|
+
params: {
|
|
65
|
+
progressToken: token,
|
|
66
|
+
progress: done,
|
|
67
|
+
...(total !== undefined ? { total } : {}),
|
|
68
|
+
...(message ? { message } : {}),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=interaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.js","sourceRoot":"","sources":["../../src/mcp/interaction.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAGlG,MAAM,WAAW,GAAG,gBAAgB,CAAA;AAoCpC,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IACxD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,GAAG,GAAG,KAAgC,CAAA;QAC5C,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;aACb,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACzC,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,IAAa;IACtC,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CACtC,SAAS,EACT,IAAI,W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G,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;YAC1B,MAAM,EAAE,wBAAwB;YAChC,MAAM,EAAE;gBACN,aAAa,EAAE,KAAK;gBACpB,QAAQ,EAAE,IAAI;gBACd,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAChC;SACF,CAAC,CAAA;IACJ,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type GetPromptResult, type McpServer, type ReadResourceResult } from "@modelcontextprotocol/server";
|
|
2
|
+
import type { Context } from "hono";
|
|
3
|
+
import type { z } from "zod";
|
|
4
|
+
import type { VerifiedToken } from "../oauth-rs/verify.js";
|
|
5
|
+
import { type ToolErrorOptions } from "./errors.js";
|
|
6
|
+
import type { ToolContext } from "./server.js";
|
|
7
|
+
type ObjectSchema = z.ZodType<Record<string, unknown>>;
|
|
8
|
+
export type ResourceContext = Omit<ToolContext, "tool"> & {
|
|
9
|
+
resource: string;
|
|
10
|
+
};
|
|
11
|
+
export type PromptContext = Omit<ToolContext, "tool"> & {
|
|
12
|
+
prompt: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function resourceResult(result: ReadResourceResult): ReadResourceResult;
|
|
15
|
+
export type ResourceReturn = unknown;
|
|
16
|
+
export type ListedResource = {
|
|
17
|
+
uri: string;
|
|
18
|
+
name: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
mimeType?: string;
|
|
22
|
+
};
|
|
23
|
+
type ResourceCommon = {
|
|
24
|
+
name: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
mimeType?: string;
|
|
28
|
+
scopes?: string[];
|
|
29
|
+
};
|
|
30
|
+
export type ResourceDefinition = ResourceCommon & ({
|
|
31
|
+
uri: string;
|
|
32
|
+
template?: never;
|
|
33
|
+
list?: never;
|
|
34
|
+
read: (req: {
|
|
35
|
+
uri: URL;
|
|
36
|
+
}, ctx: ResourceContext) => ResourceReturn | Promise<ResourceReturn>;
|
|
37
|
+
} | {
|
|
38
|
+
template: string;
|
|
39
|
+
uri?: never;
|
|
40
|
+
list?: (ctx: ResourceContext) => ListedResource[] | Promise<ListedResource[]>;
|
|
41
|
+
read: (req: {
|
|
42
|
+
uri: URL;
|
|
43
|
+
variables: Record<string, string>;
|
|
44
|
+
}, ctx: ResourceContext) => ResourceReturn | Promise<ResourceReturn>;
|
|
45
|
+
});
|
|
46
|
+
export type McpResource = ResourceDefinition & {
|
|
47
|
+
readonly kind: "resource";
|
|
48
|
+
};
|
|
49
|
+
export declare function defineResource(def: ResourceDefinition): McpResource;
|
|
50
|
+
export type PromptMessageInput = string | {
|
|
51
|
+
role: "user" | "assistant";
|
|
52
|
+
content: string;
|
|
53
|
+
} | GetPromptResult["messages"][number];
|
|
54
|
+
export type PromptReturn = string | PromptMessageInput[] | GetPromptResult;
|
|
55
|
+
export type PromptDefinition<S extends ObjectSchema | undefined = undefined> = {
|
|
56
|
+
name: string;
|
|
57
|
+
title?: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
args?: S;
|
|
60
|
+
scopes?: string[];
|
|
61
|
+
render: (args: S extends ObjectSchema ? z.output<S> : Record<never, never>, ctx: PromptContext) => PromptReturn | Promise<PromptReturn>;
|
|
62
|
+
};
|
|
63
|
+
export type McpPrompt = {
|
|
64
|
+
readonly kind: "prompt";
|
|
65
|
+
readonly name: string;
|
|
66
|
+
readonly title?: string;
|
|
67
|
+
readonly description?: string;
|
|
68
|
+
readonly args?: ObjectSchema;
|
|
69
|
+
readonly scopes?: readonly string[];
|
|
70
|
+
readonly render: (args: never, ctx: PromptContext) => unknown;
|
|
71
|
+
};
|
|
72
|
+
export declare function definePrompt<S extends ObjectSchema | undefined = undefined>(def: PromptDefinition<S>): McpPrompt;
|
|
73
|
+
type Deps = {
|
|
74
|
+
options: ToolErrorOptions;
|
|
75
|
+
context: {
|
|
76
|
+
c?: Context;
|
|
77
|
+
token?: VerifiedToken;
|
|
78
|
+
confirmSupport: ToolContext["confirmSupport"];
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export declare function registerResources(server: McpServer, resources: readonly McpResource[], deps: Deps): void;
|
|
82
|
+
export declare function registerPrompts(server: McpServer, prompts: readonly McpPrompt[], deps: Deps): void;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/mcp/primitives.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,SAAS,EAGd,KAAK,kBAAkB,EAIxB,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,KAAK,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAGtD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9E,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAK1E,wBAAgB,cAAc,C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ACnC,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,KAAK,OAAO,CAAA;CAC9D,CAAA;AAGD,wBAAgB,YAAY,CAAC,CAAC,SAAS,YAAY,GAAG,SAAS,GAAG,SAAS,EACzE,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,GACvB,SAAS,CAEX;AAED,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,gBAAgB,CAAA;IACzB,OAAO,EAAE;QAAE,CAAC,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,aAAa,CAAC;QAAC,cAAc,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAA;KAAE,CAAA;CAC/F,CAAA;AA+ED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,SAAS,WAAW,EAAE,EACjC,IAAI,EAAE,IAAI,GACT,IAAI,CAsDN;AAyBD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,SAAS,EAAE,EAC7B,IAAI,EAAE,IAAI,GACT,IAAI,CA0BN"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { isInputRequiredResult, ProtocolError, ProtocolErrorCode, ResourceNotFoundError, ResourceTemplate, } from "@modelcontextprotocol/server";
|
|
2
|
+
import { describeToolError, isHttpException, isZodError, report, } from "./errors.js";
|
|
3
|
+
const RAW = Symbol.for("signet.mcp.rawResult");
|
|
4
|
+
export function resourceResult(result) {
|
|
5
|
+
return Object.defineProperty({ ...result }, RAW, { value: true, enumerable: false });
|
|
6
|
+
}
|
|
7
|
+
export function defineResource(def) {
|
|
8
|
+
return { ...def, kind: "resource" };
|
|
9
|
+
}
|
|
10
|
+
export function definePrompt(def) {
|
|
11
|
+
return { ...def, kind: "prompt" };
|
|
12
|
+
}
|
|
13
|
+
function protocolError(err, deps, meta) {
|
|
14
|
+
if (ProtocolError.isInstance(err))
|
|
15
|
+
return err;
|
|
16
|
+
const info = deps.options.mapError?.(err) ?? describeToolError(err);
|
|
17
|
+
if (!info) {
|
|
18
|
+
report(deps.options, err, meta, deps.context.c);
|
|
19
|
+
return new ProtocolError(ProtocolErrorCode.InternalError, "Internal error");
|
|
20
|
+
}
|
|
21
|
+
const status = isHttpException(err) ? err.status : isZodError(err) ? 400 : undefined;
|
|
22
|
+
const code = status !== undefined && status >= 500
|
|
23
|
+
? ProtocolErrorCode.InternalError
|
|
24
|
+
: ProtocolErrorCode.InvalidParams;
|
|
25
|
+
return new ProtocolError(code, `${info.code}: ${info.message}`, {
|
|
26
|
+
success: false,
|
|
27
|
+
error: info.message,
|
|
28
|
+
code: info.code,
|
|
29
|
+
...(info.details ? { details: info.details } : {}),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function checkScopes(scopes, token) {
|
|
33
|
+
if (!scopes?.length)
|
|
34
|
+
return;
|
|
35
|
+
const missing = scopes.filter((s) => !token?.scopes.includes(s));
|
|
36
|
+
if (!missing.length)
|
|
37
|
+
return;
|
|
38
|
+
const message = `This token is missing the scope: ${missing.join(" ")}. Request a new token with it and try again.`;
|
|
39
|
+
throw new ProtocolError(ProtocolErrorCode.InvalidRequest, `insufficient_scope: ${message}`, {
|
|
40
|
+
success: false,
|
|
41
|
+
error: message,
|
|
42
|
+
code: "insufficient_scope",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function baseContext(mcp, deps) {
|
|
46
|
+
const { c, token, confirmSupport } = deps.context;
|
|
47
|
+
return {
|
|
48
|
+
signal: mcp.mcpReq.signal,
|
|
49
|
+
mcp,
|
|
50
|
+
confirmSupport,
|
|
51
|
+
...(c ? { c } : {}),
|
|
52
|
+
...(token ? { token } : {}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function toContents(uri, value, mimeType) {
|
|
56
|
+
if (value !== null && typeof value === "object" && RAW in value)
|
|
57
|
+
return value;
|
|
58
|
+
if (typeof value === "string")
|
|
59
|
+
return { contents: [{ uri: uri.href, mimeType: mimeType ?? "text/plain", text: value }] };
|
|
60
|
+
if (value instanceof Uint8Array) {
|
|
61
|
+
let bin = "";
|
|
62
|
+
for (const b of value)
|
|
63
|
+
bin += String.fromCharCode(b);
|
|
64
|
+
return {
|
|
65
|
+
contents: [
|
|
66
|
+
{ uri: uri.href, mimeType: mimeType ?? "application/octet-stream", blob: btoa(bin) },
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
contents: [
|
|
72
|
+
{ uri: uri.href, mimeType: mimeType ?? "application/json", text: JSON.stringify(value) },
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export function registerResources(server, resources, deps) {
|
|
77
|
+
const register = server.registerResource.bind(server);
|
|
78
|
+
for (const r of resources) {
|
|
79
|
+
const meta = { tool: r.name, kind: "resource" };
|
|
80
|
+
const ctxOf = (mcp) => ({
|
|
81
|
+
resource: r.name,
|
|
82
|
+
...baseContext(mcp, deps),
|
|
83
|
+
});
|
|
84
|
+
const run = async (uri, variables, mcp) => {
|
|
85
|
+
checkScopes(r.scopes, deps.context.token);
|
|
86
|
+
let value;
|
|
87
|
+
try {
|
|
88
|
+
const read = r.read;
|
|
89
|
+
value = await read(r.uri !== undefined ? { uri } : { uri, variables }, ctxOf(mcp));
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
throw protocolError(err, deps, meta);
|
|
93
|
+
}
|
|
94
|
+
if (value === null || value === undefined)
|
|
95
|
+
throw new ResourceNotFoundError(uri.href);
|
|
96
|
+
if (isInputRequiredResult(value))
|
|
97
|
+
return value;
|
|
98
|
+
return toContents(uri, value, r.mimeType);
|
|
99
|
+
};
|
|
100
|
+
const config = {
|
|
101
|
+
...(r.title ? { title: r.title } : {}),
|
|
102
|
+
...(r.description ? { description: r.description } : {}),
|
|
103
|
+
...(r.mimeType ? { mimeType: r.mimeType } : {}),
|
|
104
|
+
};
|
|
105
|
+
if (r.uri !== undefined) {
|
|
106
|
+
register(r.name, r.uri, config, (uri, mcp) => run(uri, {}, mcp));
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const list = r.list;
|
|
110
|
+
const template = new ResourceTemplate(r.template, {
|
|
111
|
+
list: list
|
|
112
|
+
? async (mcp) => {
|
|
113
|
+
try {
|
|
114
|
+
checkScopes(r.scopes, deps.context.token);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return { resources: [] };
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
return { resources: await list(ctxOf(mcp)) };
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
throw protocolError(err, deps, meta);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
: undefined,
|
|
127
|
+
});
|
|
128
|
+
register(r.name, template, config, (uri, vars, mcp) => {
|
|
129
|
+
const variables = {};
|
|
130
|
+
for (const [k, v] of Object.entries((vars ?? {})))
|
|
131
|
+
variables[k] = Array.isArray(v) ? (v[0] ?? "") : v;
|
|
132
|
+
return run(uri, variables, mcp);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function toPromptResult(value) {
|
|
137
|
+
if (isInputRequiredResult(value))
|
|
138
|
+
return value;
|
|
139
|
+
if (typeof value === "string")
|
|
140
|
+
return { messages: [{ role: "user", content: { type: "text", text: value } }] };
|
|
141
|
+
if (Array.isArray(value))
|
|
142
|
+
return {
|
|
143
|
+
messages: value.map((m) => typeof m === "string"
|
|
144
|
+
? { role: "user", content: { type: "text", text: m } }
|
|
145
|
+
: typeof m.content === "string"
|
|
146
|
+
? { role: m.role, content: { type: "text", text: m.content } }
|
|
147
|
+
: m),
|
|
148
|
+
};
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
export function registerPrompts(server, prompts, deps) {
|
|
152
|
+
const register = server.registerPrompt.bind(server);
|
|
153
|
+
for (const p of prompts) {
|
|
154
|
+
const meta = { tool: p.name, kind: "prompt" };
|
|
155
|
+
const run = async (args, mcp) => {
|
|
156
|
+
checkScopes(p.scopes, deps.context.token);
|
|
157
|
+
try {
|
|
158
|
+
const render = p.render;
|
|
159
|
+
return toPromptResult(await render(args, { prompt: p.name, ...baseContext(mcp, deps) }));
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
throw protocolError(err, deps, meta);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
register(p.name, {
|
|
166
|
+
...(p.title ? { title: p.title } : {}),
|
|
167
|
+
...(p.description ? { description: p.description } : {}),
|
|
168
|
+
...(p.args ? { argsSchema: p.args } : {}),
|
|
169
|
+
}, p.args
|
|
170
|
+
? (args, mcp) => run(args, mcp)
|
|
171
|
+
: (mcp) => run({}, mcp));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/mcp/primitives.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,qBAAqB,EAErB,aAAa,EACb,iBAAiB,EAEjB,qBAAqB,EACrB,gBAAgB,GAEjB,MAAM,8BAA8B,CAAA;AAIrC,OAAO,EACL,iBAAiB,EAEjB,eAAe,EACf,UAAU,EACV,MAAM,GAEP,MAAM,aAAa,CAAA;AAUpB,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;AAG9C,MAAM,UAAU,cAAc,CAAC,MAA0B;IACvD,OAAO,MAAM,CAAC,cAAc,CAAC,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAA;AACtF,CAAC;AA0DD,MAAM,UAAU,cAAc,CAAC,GAAuB;IACpD,OAAO,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,UAAU,EAAiB,CAAA;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