@mozilla-ai/mcpd 0.0.1 → 0.0.3

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/README.md CHANGED
@@ -9,14 +9,15 @@ This SDK provides high-level and dynamic access to those tools, making it easy t
9
9
  ## Features
10
10
 
11
11
  - Discover and list available `mcpd` hosted MCP servers
12
- - Retrieve tool definitions and schemas for one or all servers
12
+ - Retrieve tool, prompt, and resource definitions from individual servers
13
13
  - Dynamically invoke any tool using a clean, attribute-based syntax
14
- - Unified AI framework integration - works directly with LangChain JS and Vercel AI SDK
14
+ - Unified AI framework integration - works directly with LangChain JS and Vercel AI SDK via `getAgentTools()`
15
15
  - Generate self-contained, framework-compatible tool functions without conversion layers
16
16
  - Multiple output formats (`'array'`, `'object'`, `'map'`) for different framework needs
17
17
  - Full TypeScript support with comprehensive type definitions and overloads
18
18
  - Minimal dependencies (`lru-cache` for caching, `zod` for schema validation)
19
19
  - Works in both Node.js and browser environments
20
+ - Clean API wrapper over mcpd HTTP endpoints - no opinionated aggregation logic
20
21
 
21
22
  ## Installation
22
23
 
@@ -47,7 +48,7 @@ console.log(servers);
47
48
  // Example: ['time', 'fetch', 'git']
48
49
 
49
50
  // List tool definitions for a specific server
50
- const tools = await client.servers.time.listTools();
51
+ const tools = await client.servers.time.getTools();
51
52
  console.log(tools);
52
53
 
53
54
  // Dynamically call a tool via the .tools namespace
@@ -79,7 +80,7 @@ const client = new McpdClient({
79
80
  const servers: string[] = await client.listServers();
80
81
 
81
82
  // Get tools with proper typing
82
- const tools: Tool[] = await client.servers.time.listTools();
83
+ const tools: Tool[] = await client.servers.time.getTools();
83
84
 
84
85
  // Dynamic tool invocation with error handling via .tools namespace
85
86
  try {
@@ -122,38 +123,13 @@ const servers = await client.listServers();
122
123
  // Returns: ['time', 'fetch', 'git']
123
124
  ```
124
125
 
125
- #### `client.getToolSchemas(options?)`
126
-
127
- Returns tool schemas from all (or specific) servers with names transformed to `serverName__toolName` format.
128
-
129
- **IMPORTANT**: Tool names are automatically transformed to prevent naming clashes and identify server origin. Original tool name `get_current_time` on server `time` becomes `time__get_current_time`.
130
-
131
- This is useful for:
132
-
133
- - MCP servers aggregating and re-exposing tools from multiple upstream servers
134
- - Tool inspection and discovery across all servers
135
- - Custom tooling that needs raw MCP tool schemas with unique names
136
-
137
- ```typescript
138
- // Get all tools from all servers
139
- const allTools = await client.getToolSchemas();
140
- // Returns: [
141
- // { name: "time__get_current_time", description: "...", inputSchema: {...} },
142
- // { name: "fetch__fetch_url", description: "...", inputSchema: {...} },
143
- // { name: "git__commit", description: "...", inputSchema: {...} }
144
- // ]
145
-
146
- // Get tools from specific servers only
147
- const someTools = await client.getToolSchemas({ servers: ["time", "fetch"] });
148
- ```
149
-
150
- #### `client.servers.<server>.listTools()`
126
+ #### `client.servers.<server>.getTools()`
151
127
 
152
128
  Returns tool schemas for a specific server.
153
129
 
154
130
  ```typescript
155
131
  // Get tools for a specific server
156
- const timeTools = await client.servers.time.listTools();
132
+ const timeTools = await client.servers.time.getTools();
157
133
  // Returns: [{ name: 'get_current_time', description: '...', inputSchema: {...} }]
158
134
  ```
159
135
 
@@ -172,13 +148,13 @@ const result = await client.servers.weather.tools.get_forecast({
172
148
  const time = await client.servers.time.tools.get_current_time();
173
149
  ```
174
150
 
175
- #### `client.servers.<server>.listTools()`
151
+ #### `client.servers.<server>.getTools()`
176
152
 
177
- List all tools available on a specific server.
153
+ Get all tools available on a specific server.
178
154
 
179
155
  ```typescript
180
156
  // List tools for a server using property access
181
- const tools = await client.servers.time.listTools();
157
+ const tools = await client.servers.time.getTools();
182
158
  for (const tool of tools) {
183
159
  console.log(`${tool.name}: ${tool.description}`);
184
160
  }
@@ -186,7 +162,7 @@ for (const tool of tools) {
186
162
  // Useful in loops with dynamic server names
187
163
  const servers = await client.listServers();
188
164
  for (const serverName of servers) {
189
- const tools = await client.servers[serverName].listTools();
165
+ const tools = await client.servers[serverName].getTools();
190
166
  console.log(`${serverName}: ${tools.length} tools`);
191
167
  }
192
168
  ```
@@ -228,6 +204,130 @@ if (await client.servers[serverName].hasTool("get_current_time")) {
228
204
  }
229
205
  ```
230
206
 
207
+ #### `client.servers.<server>.getPrompts()`
208
+
209
+ Returns prompt schemas for a specific server.
210
+
211
+ ```typescript
212
+ // Get prompts for a specific server
213
+ const githubPrompts = await client.servers.github.getPrompts();
214
+ // Returns: [{ name: 'create_pr', description: '...', arguments: [...] }]
215
+ ```
216
+
217
+ #### `client.servers.<server>.prompts.<prompt>(args)`
218
+
219
+ Dynamically generate any prompt using natural syntax via the `.prompts` namespace. Prompt names must match exactly as returned by the MCP server.
220
+
221
+ ```typescript
222
+ // Generate a prompt with parameters using property access (recommended)
223
+ const result = await client.servers.github.prompts.create_pr({
224
+ title: "Fix bug",
225
+ description: "Fixed authentication issue",
226
+ });
227
+
228
+ // Generate without parameters (if prompt has no required args)
229
+ const result = await client.servers.templates.prompts.default_template();
230
+ ```
231
+
232
+ #### `client.servers.<server>.generatePrompt(promptName, args?)`
233
+
234
+ Generate a prompt by name with the given arguments. This is useful for programmatic prompt generation when the prompt name is in a variable.
235
+
236
+ ```typescript
237
+ // Generate with dynamic prompt name
238
+ const promptName = "create_pr";
239
+ const result = await client.servers.github.generatePrompt(promptName, {
240
+ title: "Fix bug",
241
+ description: "Fixed authentication issue",
242
+ });
243
+
244
+ // Using with dynamic server name too
245
+ const serverName = "github";
246
+ const result2 = await client.servers[serverName].generatePrompt(promptName, {
247
+ title: "Fix bug",
248
+ });
249
+ ```
250
+
251
+ #### `client.servers.<server>.hasPrompt(promptName)`
252
+
253
+ Check if a specific prompt exists on a server. Prompt names must match exactly as returned by the MCP server.
254
+
255
+ ```typescript
256
+ // Check if prompt exists before generating it
257
+ if (await client.servers.github.hasPrompt("create_pr")) {
258
+ const result = await client.servers.github.generatePrompt("create_pr", {
259
+ title: "Fix bug",
260
+ });
261
+ }
262
+
263
+ // Using with dynamic server names
264
+ const serverName = "github";
265
+ if (await client.servers[serverName].hasPrompt("create_pr")) {
266
+ const result = await client.servers[serverName].prompts.create_pr({
267
+ title: "Fix bug",
268
+ });
269
+ }
270
+ ```
271
+
272
+ #### `client.servers.<server>.getResources()`
273
+
274
+ Returns resource schemas for a specific server.
275
+
276
+ ```typescript
277
+ // Get resources for a specific server
278
+ const githubResources = await client.servers.github.getResources();
279
+ // Returns: [{ name: 'readme', uri: 'file:///repo/README.md', ... }]
280
+ ```
281
+
282
+ #### `client.servers.<server>.getResourceTemplates()`
283
+
284
+ Returns resource template schemas for a specific server.
285
+
286
+ ```typescript
287
+ // Get resource templates for a specific server
288
+ const githubTemplates = await client.servers.github.getResourceTemplates();
289
+ // Returns: [{ name: 'file', uriTemplate: 'file:///{path}', ... }]
290
+ ```
291
+
292
+ #### `client.servers.<server>.readResource(uri)`
293
+
294
+ Read resource content by URI from a specific server.
295
+
296
+ ```typescript
297
+ // Read resource content by URI
298
+ const contents = await client.servers.github.readResource(
299
+ "file:///repo/README.md",
300
+ );
301
+ for (const content of contents) {
302
+ if (content.text) {
303
+ console.log(content.text);
304
+ } else if (content.blob) {
305
+ console.log("Binary content (base64):", content.blob);
306
+ }
307
+ }
308
+ ```
309
+
310
+ #### `client.servers.<server>.hasResource(uri)`
311
+
312
+ Check if a specific resource exists on a server. Resource URIs must match exactly as returned by the MCP server.
313
+
314
+ ```typescript
315
+ // Check if resource exists before reading it
316
+ if (await client.servers.github.hasResource("file:///repo/README.md")) {
317
+ const contents = await client.servers.github.readResource(
318
+ "file:///repo/README.md",
319
+ );
320
+ }
321
+
322
+ // Using with dynamic server names
323
+ const serverName = "github";
324
+ if (await client.servers[serverName].hasResource("file:///repo/README.md")) {
325
+ const contents = await client.servers[serverName].readResource(
326
+ "file:///repo/README.md",
327
+ );
328
+ }
329
+ ```
330
+
231
331
  #### `client.getServerHealth(serverName?: string)`
232
332
 
233
333
  Get health information for one or all servers.
@@ -402,6 +502,9 @@ npm run test:coverage
402
502
  ### Linting and Formatting
403
503
 
404
504
  ```bash
505
+ # Run all checks (format, lint, typecheck, test, build)
506
+ npm run check
507
+
405
508
  # Run linter
406
509
  npm run lint
407
510
 
@@ -5,6 +5,11 @@ export declare const API_PATHS: {
5
5
  readonly SERVERS: "/api/v1/servers";
6
6
  readonly SERVER_TOOLS: (serverName: string) => string;
7
7
  readonly TOOL_CALL: (serverName: string, toolName: string) => string;
8
+ readonly SERVER_PROMPTS: (serverName: string, cursor?: string) => string;
9
+ readonly PROMPT_GET_GENERATED: (serverName: string, promptName: string) => string;
10
+ readonly SERVER_RESOURCES: (serverName: string, cursor?: string) => string;
11
+ readonly SERVER_RESOURCE_TEMPLATES: (serverName: string, cursor?: string) => string;
12
+ readonly RESOURCE_CONTENT: (serverName: string, uri: string) => string;
8
13
  readonly HEALTH_ALL: "/api/v1/health/servers";
9
14
  readonly HEALTH_SERVER: (serverName: string) => string;
10
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"apiPaths.d.ts","sourceRoot":"","sources":["../src/apiPaths.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,eAAO,MAAM,SAAS;;wCAKO,MAAM;qCAET,MAAM,YAAY,MAAM;;yCAKpB,MAAM;CAE1B,CAAC"}
1
+ {"version":3,"file":"apiPaths.d.ts","sourceRoot":"","sources":["../src/apiPaths.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,eAAO,MAAM,SAAS;;wCAKO,MAAM;qCAET,MAAM,YAAY,MAAM;0CAInB,MAAM,WAAW,MAAM;gDAIjB,MAAM,cAAc,MAAM;4CAI9B,MAAM,WAAW,MAAM;qDAId,MAAM,WAAW,MAAM;4CAIhC,MAAM,OAAO,MAAM;;yCAKtB,MAAM;CAE1B,CAAC"}
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { McpdClientOptions, ServerHealth, Tool } from './types';
1
+ import { McpdClientOptions, ServerHealth } from './types';
2
2
  import { ServersNamespace } from './dynamicCaller';
3
3
  import { AgentFunction } from './functionBuilder';
4
4
  /**
@@ -57,51 +57,6 @@ export declare class McpdClient {
57
57
  * ```
58
58
  */
59
59
  listServers(): Promise<string[]>;
60
- /**
61
- * Get tool schemas from all (or specific) MCP servers with transformed names.
62
- *
63
- * IMPORTANT: Tool names are transformed to `serverName__toolName` format to:
64
- * 1. Prevent naming clashes when aggregating tools from multiple servers
65
- * 2. Identify which server each tool belongs to
66
- *
67
- * This method automatically filters out unhealthy servers by checking their health
68
- * status before fetching tools. Unhealthy servers are silently skipped to ensure
69
- * the method returns quickly without waiting for timeouts on failed servers.
70
- *
71
- * Tool fetches from multiple servers are executed concurrently for optimal performance.
72
- *
73
- * This is useful for:
74
- * - MCP servers that aggregate and re-expose tools from multiple upstream servers
75
- * - Tool inspection and discovery across all servers
76
- * - Custom tooling that needs raw MCP tool schemas
77
- *
78
- * @param options - Optional configuration
79
- * @param options.servers - Array of server names to include. If not specified, includes all servers.
80
- * @returns Array of tool schemas with transformed names (serverName__toolName). Only includes tools from healthy servers.
81
- * @throws {ConnectionError} If unable to connect to the mcpd daemon
82
- * @throws {TimeoutError} If requests to the daemon time out
83
- * @throws {AuthenticationError} If API key authentication fails
84
- * @throws {McpdError} If health check or initial server listing fails
85
- *
86
- * @example
87
- * ```typescript
88
- * // Get all tools from all servers
89
- * const allTools = await client.getToolSchemas();
90
- * // Returns: [
91
- * // { name: "time__get_current_time", description: "...", ... },
92
- * // { name: "fetch__fetch_url", description: "...", ... }
93
- * // ]
94
- *
95
- * // Get tools from specific servers only
96
- * const someTools = await client.getToolSchemas({ servers: ['time', 'fetch'] });
97
- *
98
- * // Original tool name "get_current_time" becomes "time__get_current_time"
99
- * // This prevents clashes if multiple servers have tools with the same name
100
- * ```
101
- */
102
- getToolSchemas(options?: {
103
- servers?: string[];
104
- }): Promise<Tool[]>;
105
60
  /**
106
61
  * Get health information for one or all servers.
107
62
  *
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAYH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GG;IACH,sBAAsB,IAAI,IAAI;IAI9B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IA6B9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACG,aAAa,CAAC,OAAO,CAAC,EAAE;QAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IACtB,aAAa,CAAC,OAAO,EAAE;QAC3B,MAAM,EAAE,QAAQ,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACpC,aAAa,CAAC,OAAO,EAAE;QAC3B,MAAM,EAAE,KAAK,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAwBxC"}
@@ -1,4 +1,4 @@
1
- import { Tool, PerformCallFn, GetToolsFn } from './types';
1
+ import { Tool, Prompt, Resource, ResourceTemplate, ResourceContent, GeneratePromptResponseBody, PerformCallFn, GetToolsFn, GetPromptsFn, GeneratePromptFn, GetResourcesFn, GetResourceTemplatesFn, ReadResourceFn } from './types';
2
2
  /**
3
3
  * Namespace for accessing MCP servers via proxy.
4
4
  *
@@ -24,10 +24,24 @@ export declare class ServersNamespace {
24
24
  /**
25
25
  * Initialize the ServersNamespace with injected functions.
26
26
  *
27
- * @param performCall - Function to execute tool calls
28
- * @param getTools - Function to get tool schemas
27
+ * @param options - Configuration object
28
+ * @param options.performCall - Function to execute tool calls
29
+ * @param options.getTools - Function to get tool schemas
30
+ * @param options.generatePrompt - Function to generate prompts
31
+ * @param options.getPrompts - Function to get prompt schemas
32
+ * @param options.getResources - Function to get resources
33
+ * @param options.getResourceTemplates - Function to get resource templates
34
+ * @param options.readResource - Function to read resource content
29
35
  */
30
- constructor(performCall: PerformCallFn, getTools: GetToolsFn);
36
+ constructor({ performCall, getTools, generatePrompt, getPrompts, getResources, getResourceTemplates, readResource, }: {
37
+ performCall: PerformCallFn;
38
+ getTools: GetToolsFn;
39
+ generatePrompt: GeneratePromptFn;
40
+ getPrompts: GetPromptsFn;
41
+ getResources: GetResourcesFn;
42
+ getResourceTemplates: GetResourceTemplatesFn;
43
+ readResource: ReadResourceFn;
44
+ });
31
45
  }
32
46
  /**
33
47
  * Represents a specific MCP server, providing access to its tools and operations.
@@ -41,7 +55,7 @@ export declare class ServersNamespace {
41
55
  * const timeServer = client.servers.time; // Returns Server(...)
42
56
  *
43
57
  * // List available tools
44
- * const tools = await timeServer.listTools();
58
+ * const tools = await timeServer.getTools();
45
59
  *
46
60
  * // Call tools through the .tools namespace:
47
61
  * await timeServer.tools.get_current_time({ timezone: "UTC" })
@@ -50,16 +64,22 @@ export declare class ServersNamespace {
50
64
  export declare class Server {
51
65
  #private;
52
66
  readonly tools: ToolsNamespace;
67
+ readonly prompts: PromptsNamespace;
53
68
  /**
54
69
  * Initialize a Server for a specific server.
55
70
  *
56
71
  * @param performCall - Function to execute tool calls
57
72
  * @param getTools - Function to get tool schemas
73
+ * @param generatePrompt - Function to generate prompts
74
+ * @param getPrompts - Function to get prompt schemas
75
+ * @param getResources - Function to get resources
76
+ * @param getResourceTemplates - Function to get resource templates
77
+ * @param readResource - Function to read resource content
58
78
  * @param serverName - The name of the MCP server
59
79
  */
60
- constructor(performCall: PerformCallFn, getTools: GetToolsFn, serverName: string);
80
+ constructor(performCall: PerformCallFn, getTools: GetToolsFn, generatePrompt: GeneratePromptFn, getPrompts: GetPromptsFn, getResources: GetResourcesFn, getResourceTemplates: GetResourceTemplatesFn, readResource: ReadResourceFn, serverName: string);
61
81
  /**
62
- * List all tools available on this server.
82
+ * Get all tools available on this server.
63
83
  *
64
84
  * @returns Array of tool schemas
65
85
  * @throws {ServerNotFoundError} If the server doesn't exist
@@ -67,20 +87,25 @@ export declare class Server {
67
87
  *
68
88
  * @example
69
89
  * ```typescript
70
- * const tools = await client.servers.time.listTools();
90
+ * const tools = await client.servers.time.getTools();
71
91
  * for (const tool of tools) {
72
92
  * console.log(`${tool.name}: ${tool.description}`);
73
93
  * }
74
94
  * ```
75
95
  */
76
- listTools(): Promise<Tool[]>;
96
+ getTools(): Promise<Tool[]>;
77
97
  /**
78
98
  * Check if a tool exists on this server.
79
99
  *
80
100
  * The tool name must match exactly as returned by the server.
81
101
  *
102
+ * This method is designed as a safe boolean predicate - it catches all errors
103
+ * (ServerNotFoundError, ServerUnhealthyError, ConnectionError, etc.) and returns
104
+ * false rather than throwing. This makes it safe to use in conditional checks
105
+ * without requiring error handling.
106
+ *
82
107
  * @param toolName - The exact name of the tool to check
83
- * @returns True if the tool exists, false otherwise
108
+ * @returns True if the tool exists, false otherwise (including on errors)
84
109
  *
85
110
  * @example
86
111
  * ```typescript
@@ -113,6 +138,152 @@ export declare class Server {
113
138
  * ```
114
139
  */
115
140
  callTool(toolName: string, args?: Record<string, unknown>): Promise<unknown>;
141
+ /**
142
+ * Get all prompts available on this server.
143
+ *
144
+ * Note: This method is marked `async` for consistency with other server methods,
145
+ * even though it doesn't directly await. This maintains a uniform async interface
146
+ * and allows for future enhancements without breaking the API contract.
147
+ *
148
+ * @returns Array of prompt schemas
149
+ * @throws {ServerNotFoundError} If the server doesn't exist
150
+ * @throws {ServerUnhealthyError} If the server is unhealthy
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * const prompts = await client.servers.github.getPrompts();
155
+ * for (const prompt of prompts) {
156
+ * console.log(`${prompt.name}: ${prompt.description}`);
157
+ * }
158
+ * ```
159
+ */
160
+ getPrompts(): Promise<Prompt[]>;
161
+ /**
162
+ * Check if a prompt exists on this server.
163
+ *
164
+ * The prompt name must match exactly as returned by the server.
165
+ *
166
+ * This method is designed as a safe boolean predicate - it catches all errors
167
+ * (ServerNotFoundError, ServerUnhealthyError, ConnectionError, etc.) and returns
168
+ * false rather than throwing. This makes it safe to use in conditional checks
169
+ * without requiring error handling.
170
+ *
171
+ * @param promptName - The exact name of the prompt to check
172
+ * @returns True if the prompt exists, false otherwise (including on errors)
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * if (await client.servers.github.hasPrompt('create_pr')) {
177
+ * const result = await client.servers.github.generatePrompt('create_pr', { title: 'Fix bug' });
178
+ * }
179
+ * ```
180
+ */
181
+ hasPrompt(promptName: string): Promise<boolean>;
182
+ /**
183
+ * Generate a prompt by name with the given arguments.
184
+ *
185
+ * This method is useful for programmatic prompt generation when the prompt name
186
+ * is in a variable. The prompt name must match exactly as returned by the server.
187
+ *
188
+ * @param promptName - The exact name of the prompt to generate
189
+ * @param args - The arguments to pass to the prompt template
190
+ * @returns The generated prompt response
191
+ * @throws {ToolNotFoundError} If the prompt doesn't exist on the server
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * // Call with explicit method (useful for dynamic prompt names):
196
+ * const promptName = 'create_pr';
197
+ * await client.servers.github.generatePrompt(promptName, { title: 'Fix bug' });
198
+ *
199
+ * // Or with dynamic server name:
200
+ * const serverName = 'github';
201
+ * await client.servers[serverName].generatePrompt(promptName, { title: 'Fix bug' });
202
+ * ```
203
+ */
204
+ generatePrompt(promptName: string, args?: Record<string, string>): Promise<GeneratePromptResponseBody>;
205
+ /**
206
+ * Get all resources available on this server.
207
+ *
208
+ * Note: This method is marked `async` for consistency with other server methods,
209
+ * even though it doesn't directly await. This maintains a uniform async interface
210
+ * and allows for future enhancements without breaking the API contract.
211
+ *
212
+ * @returns Array of resource schemas with original names
213
+ * @throws {ServerNotFoundError} If the server doesn't exist
214
+ * @throws {ServerUnhealthyError} If the server is unhealthy
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * const resources = await client.servers.github.getResources();
219
+ * for (const resource of resources) {
220
+ * console.log(`${resource.name}: ${resource.uri}`);
221
+ * }
222
+ * ```
223
+ */
224
+ getResources(): Promise<Resource[]>;
225
+ /**
226
+ * Get all resource templates available on this server.
227
+ *
228
+ * Note: This method is marked `async` for consistency with other server methods,
229
+ * even though it doesn't directly await. This maintains a uniform async interface
230
+ * and allows for future enhancements without breaking the API contract.
231
+ *
232
+ * @returns Array of resource template schemas with original names
233
+ * @throws {ServerNotFoundError} If the server doesn't exist
234
+ * @throws {ServerUnhealthyError} If the server is unhealthy
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * const templates = await client.servers.github.getResourceTemplates();
239
+ * for (const template of templates) {
240
+ * console.log(`${template.name}: ${template.uriTemplate}`);
241
+ * }
242
+ * ```
243
+ */
244
+ getResourceTemplates(): Promise<ResourceTemplate[]>;
245
+ /**
246
+ * Check if a resource exists on this server.
247
+ *
248
+ * The resource URI must match exactly as returned by the server.
249
+ *
250
+ * This method is designed as a safe boolean predicate - it catches all errors
251
+ * (ServerNotFoundError, ServerUnhealthyError, ConnectionError, etc.) and returns
252
+ * false rather than throwing. This makes it safe to use in conditional checks
253
+ * without requiring error handling.
254
+ *
255
+ * @param uri - The exact URI of the resource to check
256
+ * @returns True if the resource exists, false otherwise (including on errors)
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * if (await client.servers.github.hasResource('file:///repo/README.md')) {
261
+ * const content = await client.servers.github.readResource('file:///repo/README.md');
262
+ * }
263
+ * ```
264
+ */
265
+ hasResource(uri: string): Promise<boolean>;
266
+ /**
267
+ * Read resource content by URI from this server.
268
+ *
269
+ * @param uri - The resource URI
270
+ * @returns Array of resource contents (text or blob)
271
+ * @throws {ServerNotFoundError} If the server doesn't exist
272
+ * @throws {ServerUnhealthyError} If the server is unhealthy
273
+ *
274
+ * @example
275
+ * ```typescript
276
+ * const contents = await client.servers.github.readResource('file:///repo/README.md');
277
+ * for (const content of contents) {
278
+ * if (content.text) {
279
+ * console.log(content.text);
280
+ * } else if (content.blob) {
281
+ * console.log('Binary content:', content.blob.substring(0, 50) + '...');
282
+ * }
283
+ * }
284
+ * ```
285
+ */
286
+ readResource(uri: string): Promise<ResourceContent[]>;
116
287
  }
117
288
  /**
118
289
  * Namespace for accessing tools on a specific MCP server via proxy.
@@ -143,4 +314,36 @@ export declare class ToolsNamespace {
143
314
  */
144
315
  constructor(performCall: PerformCallFn, getTools: GetToolsFn, serverName: string);
145
316
  }
317
+ /**
318
+ * Namespace for accessing prompts on a specific MCP server via proxy.
319
+ *
320
+ * This class provides the `.prompts` namespace for a server, allowing you to generate
321
+ * prompts as if they were methods. All prompt names must match exactly as returned
322
+ * by the MCP server.
323
+ *
324
+ * NOTE: Use `client.servers.foo.generatePrompt()` and `client.servers.foo.hasPrompt()`
325
+ * instead of putting them in the `.prompts` namespace to avoid collisions with
326
+ * actual prompts named "generatePrompt" or "hasPrompt".
327
+ *
328
+ * @example
329
+ * ```typescript
330
+ * // Generate prompts via .prompts namespace with static names
331
+ * const result = await client.servers.github.prompts.create_pr({
332
+ * title: "Fix bug",
333
+ * description: "Fixed auth issue"
334
+ * });
335
+ * ```
336
+ */
337
+ export declare class PromptsNamespace {
338
+ #private;
339
+ [promptName: string]: (args?: Record<string, string>) => Promise<GeneratePromptResponseBody>;
340
+ /**
341
+ * Initialize a PromptsNamespace for a specific server.
342
+ *
343
+ * @param generatePrompt - Function to generate prompts
344
+ * @param getPrompts - Function to get prompt schemas
345
+ * @param serverName - The name of the MCP server
346
+ */
347
+ constructor(generatePrompt: GeneratePromptFn, getPrompts: GetPromptsFn, serverName: string);
348
+ }
146
349
  //# sourceMappingURL=dynamicCaller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dynamicCaller.d.ts","sourceRoot":"","sources":["../src/dynamicCaller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa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