Skip to content

Commit 9dc6c9c

Browse files
committed
Had to inline getCapability(), wouldn't pass typechecking otherwise
1 parent ee7eb5e commit 9dc6c9c

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

Diff for: src/server/index.ts

+20-12
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,28 @@ export class Server extends Protocol<
8383
return this._clientVersion;
8484
}
8585

86-
private getCapability(
87-
reqType: ClientRequest["method"],
88-
): ServerCapabilities[keyof ServerCapabilities] {
89-
return this._requestHandlers.has(reqType as string) ? {} : undefined;
90-
}
91-
9286
private getCapabilities(): ServerCapabilities {
9387
return {
94-
prompts: this.getCapability(ListPromptsRequestSchema.shape.method.value),
95-
resources: this.getCapability(
96-
ListResourcesRequestSchema.shape.method.value,
97-
),
98-
tools: this.getCapability(ListToolsRequestSchema.shape.method.value),
99-
logging: this.getCapability(SetLevelRequestSchema.shape.method.value),
88+
prompts: this._requestHandlers.has(
89+
ListPromptsRequestSchema.shape.method.value as string,
90+
)
91+
? {}
92+
: undefined,
93+
resources: this._requestHandlers.has(
94+
ListResourcesRequestSchema.shape.method.value as string,
95+
)
96+
? {}
97+
: undefined,
98+
tools: this._requestHandlers.has(
99+
ListToolsRequestSchema.shape.method.value as string,
100+
)
101+
? {}
102+
: undefined,
103+
logging: this._requestHandlers.has(
104+
SetLevelRequestSchema.shape.method.value as string,
105+
)
106+
? {}
107+
: undefined,
100108
};
101109
}
102110
}

0 commit comments

Comments
 (0)