@elsium-ai/mcp 0.8.0 → 0.9.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/README.md +154 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -186,6 +186,8 @@ interface MCPServerConfig {
|
|
|
186
186
|
name: string
|
|
187
187
|
version?: string
|
|
188
188
|
tools: Tool[]
|
|
189
|
+
resources?: MCPResourceHandler[]
|
|
190
|
+
prompts?: MCPPromptHandler[]
|
|
189
191
|
}
|
|
190
192
|
```
|
|
191
193
|
|
|
@@ -194,6 +196,8 @@ interface MCPServerConfig {
|
|
|
194
196
|
| `name` | `string` | yes | -- | Server name reported in the `initialize` handshake |
|
|
195
197
|
| `version` | `string` | no | `'0.1.0'` | Server version reported in the `initialize` handshake |
|
|
196
198
|
| `tools` | `Tool[]` | yes | -- | Array of ElsiumAI `Tool` objects to expose over MCP |
|
|
199
|
+
| `resources` | `MCPResourceHandler[]` | no | `[]` | Resource handlers to expose over MCP |
|
|
200
|
+
| `prompts` | `MCPPromptHandler[]` | no | `[]` | Prompt handlers to expose over MCP |
|
|
197
201
|
|
|
198
202
|
### `MCPServer`
|
|
199
203
|
|
|
@@ -210,7 +214,7 @@ interface MCPServer {
|
|
|
210
214
|
| Member | Description |
|
|
211
215
|
| ------ | ----------- |
|
|
212
216
|
| `running` | Read-only boolean indicating whether the server is currently listening for requests |
|
|
213
|
-
| `start()` | Begin listening on `stdin` for incoming JSON-RPC messages. Handles `initialize`, `notifications/initialized`, `tools/list`,
|
|
217
|
+
| `start()` | Begin listening on `stdin` for incoming JSON-RPC messages. Handles `initialize`, `notifications/initialized`, `tools/list`, `tools/call`, `resources/list`, `resources/read`, `prompts/list`, and `prompts/get` |
|
|
214
218
|
| `stop()` | Stop the server by setting the running flag to false |
|
|
215
219
|
|
|
216
220
|
### `createMCPServer(config)`
|
|
@@ -250,8 +254,155 @@ const server = createMCPServer({
|
|
|
250
254
|
})
|
|
251
255
|
|
|
252
256
|
await server.start()
|
|
253
|
-
|
|
254
|
-
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Example -- server with resources and prompts**
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
import { createMCPServer } from '@elsium-ai/mcp'
|
|
263
|
+
import { createTool } from '@elsium-ai/tools'
|
|
264
|
+
import { z } from 'zod'
|
|
265
|
+
|
|
266
|
+
const greet = createTool({
|
|
267
|
+
name: 'greet',
|
|
268
|
+
description: 'Return a greeting for the given name',
|
|
269
|
+
input: z.object({ name: z.string() }),
|
|
270
|
+
execute: async ({ input }) => `Hello, ${input.name}!`,
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
const server = createMCPServer({
|
|
274
|
+
name: 'my-server',
|
|
275
|
+
version: '1.0.0',
|
|
276
|
+
tools: [greet],
|
|
277
|
+
resources: [
|
|
278
|
+
{
|
|
279
|
+
uri: 'config://app',
|
|
280
|
+
name: 'App Configuration',
|
|
281
|
+
description: 'Current application configuration',
|
|
282
|
+
mimeType: 'application/json',
|
|
283
|
+
read: async () => JSON.stringify({ env: 'production', version: '1.0.0' }),
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
prompts: [
|
|
287
|
+
{
|
|
288
|
+
name: 'summarize',
|
|
289
|
+
description: 'Summarize the given text',
|
|
290
|
+
arguments: [
|
|
291
|
+
{ name: 'text', description: 'Text to summarize', required: true },
|
|
292
|
+
{ name: 'style', description: 'Summary style (brief or detailed)', required: false },
|
|
293
|
+
],
|
|
294
|
+
get: async (args) => ({
|
|
295
|
+
messages: [
|
|
296
|
+
{
|
|
297
|
+
role: 'user',
|
|
298
|
+
content: `Summarize the following text in a ${args?.style ?? 'brief'} style:\n\n${args?.text}`,
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
}),
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
await server.start()
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Resources
|
|
312
|
+
|
|
313
|
+
### `MCPResourceHandler`
|
|
314
|
+
|
|
315
|
+
Defines a resource that the MCP server can expose. Resources provide read-only data to clients (configuration, files, database records, etc.).
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
interface MCPResourceHandler {
|
|
319
|
+
uri: string
|
|
320
|
+
name: string
|
|
321
|
+
description?: string
|
|
322
|
+
mimeType?: string
|
|
323
|
+
read(): Promise<string>
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
| Property | Type | Required | Description |
|
|
328
|
+
| -------- | ---- | -------- | ----------- |
|
|
329
|
+
| `uri` | `string` | yes | Unique URI identifying the resource (e.g. `'config://app'`, `'file:///data.json'`) |
|
|
330
|
+
| `name` | `string` | yes | Human-readable name for the resource |
|
|
331
|
+
| `description` | `string` | no | Description of what the resource provides |
|
|
332
|
+
| `mimeType` | `string` | no | MIME type of the returned content |
|
|
333
|
+
| `read` | `() => Promise<string>` | yes | Async function that returns the resource content as a string |
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## Prompts
|
|
338
|
+
|
|
339
|
+
### `MCPPromptHandler`
|
|
340
|
+
|
|
341
|
+
Defines a prompt template that the MCP server can expose. Prompts allow clients to request pre-built message sequences with optional arguments.
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
interface MCPPromptHandler {
|
|
345
|
+
name: string
|
|
346
|
+
description?: string
|
|
347
|
+
arguments?: MCPPromptArgument[]
|
|
348
|
+
get(args?: Record<string, string>): Promise<{ messages: Array<{ role: string; content: string }> }>
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
interface MCPPromptArgument {
|
|
352
|
+
name: string
|
|
353
|
+
description?: string
|
|
354
|
+
required?: boolean
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
| Property | Type | Required | Description |
|
|
359
|
+
| -------- | ---- | -------- | ----------- |
|
|
360
|
+
| `name` | `string` | yes | Unique name for the prompt |
|
|
361
|
+
| `description` | `string` | no | Description of what the prompt does |
|
|
362
|
+
| `arguments` | `MCPPromptArgument[]` | no | Arguments the prompt accepts |
|
|
363
|
+
| `get` | `(args?) => Promise<{ messages }>` | yes | Async function that returns the prompt's message sequence |
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Client Resource and Prompt Methods
|
|
368
|
+
|
|
369
|
+
The `MCPClient` also supports listing and reading resources and prompts from a connected server:
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
interface MCPClient {
|
|
373
|
+
listResources(): Promise<MCPResourceInfo[]>
|
|
374
|
+
readResource(uri: string): Promise<string>
|
|
375
|
+
listPrompts(): Promise<MCPPromptInfo[]>
|
|
376
|
+
getPrompt(name: string, args?: Record<string, string>): Promise<{ messages: Array<{ role: string; content: string }> }>
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
| Method | Description |
|
|
381
|
+
| ------ | ----------- |
|
|
382
|
+
| `listResources()` | List all resources exposed by the connected MCP server |
|
|
383
|
+
| `readResource(uri)` | Read the content of a specific resource by URI |
|
|
384
|
+
| `listPrompts()` | List all prompts exposed by the connected MCP server |
|
|
385
|
+
| `getPrompt(name, args?)` | Get a prompt's message sequence, optionally passing arguments |
|
|
386
|
+
|
|
387
|
+
```typescript
|
|
388
|
+
import { createMCPClient } from '@elsium-ai/mcp'
|
|
389
|
+
|
|
390
|
+
const client = createMCPClient({
|
|
391
|
+
name: 'my-client',
|
|
392
|
+
transport: 'stdio',
|
|
393
|
+
command: 'node',
|
|
394
|
+
args: ['./my-mcp-server.js'],
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
await client.connect()
|
|
398
|
+
|
|
399
|
+
const resources = await client.listResources()
|
|
400
|
+
const config = await client.readResource('config://app')
|
|
401
|
+
|
|
402
|
+
const prompts = await client.listPrompts()
|
|
403
|
+
const prompt = await client.getPrompt('summarize', { text: 'Long article...', style: 'brief' })
|
|
404
|
+
|
|
405
|
+
await client.disconnect()
|
|
255
406
|
```
|
|
256
407
|
|
|
257
408
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elsium-ai/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Model Context Protocol (MCP) support for ElsiumAI — bidirectional bridge",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Eric Utrera <ebutrera9103@gmail.com>",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"dev": "bun --watch src/index.ts"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@elsium-ai/core": "^0.
|
|
30
|
-
"@elsium-ai/tools": "^0.
|
|
29
|
+
"@elsium-ai/core": "^0.9.1",
|
|
30
|
+
"@elsium-ai/tools": "^0.9.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"typescript": "^5.7.0"
|