feat(mcp): add resource read tools (#33483)

This commit is contained in:
Shoubhit Dash
2026-06-23 13:49:42 +05:30
committed by GitHub
parent e9b1db5316
commit b94c2b0562
8 changed files with 376 additions and 22 deletions
+5 -1
View File
@@ -86,6 +86,7 @@ export function fetch<T extends { name: string }>(
client: Client,
list: (client: Client) => Promise<T[]>,
label: string,
key?: (item: T) => string,
) {
return Effect.tryPromise({
try: () => list(client),
@@ -100,7 +101,10 @@ export function fetch<T extends { name: string }>(
Effect.map((items) => {
const sanitizedClient = sanitize(clientName)
return Object.fromEntries(
items.map((item) => [sanitizedClient + ":" + sanitize(item.name), { ...item, client: clientName }]),
items.map((item) => [
key ? clientName + ":" + key(item) : sanitizedClient + ":" + sanitize(item.name),
{ ...item, client: clientName },
]),
)
}),
Effect.orElseSucceed(() => undefined),