History

Merge remote-tracking branch 'origin/codex/effect-lint-mcp-manifest' into codex/effect-lint-integration

Rhys Sullivan committed 6 months ago

Commit b9a25b42 parents 2d588fc 0fab4571 file · +15 −13Browse files

Unified · Split

packages/plugins/mcp/src/sdk/manifest.ts+15−13
@@ -1,4 +1,4 @@
1−import { Schema } from "effect";
1+import { Option, Schema } from "effect";
22
33 import { McpToolAnnotations } from "./types";
44
@@ -51,7 +51,7 @@ const decodeListToolsResult = Schema.decodeUnknownOption(ListToolsResult); · 46 unmodified lines
5151 const decodeServerInfo = Schema.decodeUnknownOption(ServerInfo);
5252
5353 export const isListToolsResult = (value: unknown): boolean =>
54− decodeListToolsResult(value)._tag === "Some";
54+ Option.isSome(decodeListToolsResult(value));
5555
5656 // ---------------------------------------------------------------------------
5757 // Tool ID sanitization
@@ -86,14 +86,19 @@ export const extractManifestFromListToolsResult = ( · 28 unmodified lines
8686 ): McpToolManifest => {
8787 const seen = new Map<string, number>();
8888
89− const listed = decodeListToolsResult(listToolsResult).pipe((opt) =>
90− opt._tag === "Some" ? opt.value.tools : [],
89+ const listed = decodeListToolsResult(listToolsResult).pipe(
90+ Option.map((result) => result.tools),
91+ Option.getOrElse(() => []),
9192 );
9293
93− const server = decodeServerInfo(metadata?.serverInfo).pipe((opt): McpServerMetadata | null =>
94− opt._tag === "Some"
95− ? { name: opt.value.name ?? null, version: opt.value.version ?? null }
96− : null,
94+ const server = decodeServerInfo(metadata?.serverInfo).pipe(
95+ Option.map(
96+ (info): McpServerMetadata => ({
97+ name: info.name ?? null,
98+ version: info.version ?? null,
99+ }),
100+ ),
101+ Option.getOrNull,
97102 );
98103
99104 const tools = listed.flatMap((tool): McpToolManifestEntry[] => {
@@ -126,11 +131,8 @@ const slugify = (value: string): string => · 26 unmodified lines
126131 .replace(/^_+|_+$/g, "");
127132
128133 const hostnameOf = (url: string): string | null => {
129− try {
130− return new URL(url).hostname;
131− } catch {
132− return null;
133− }
134+ if (!URL.canParse(url)) return null;
135+ return new URL(url).hostname;
134136 };
135137
136138 const basenameOf = (path: string): string => path.trim().split(/[\\/]/).pop() ?? path.trim();