@mcpflo/server-everything 0.0.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.
Files changed (44) hide show
  1. package/README.md +84 -0
  2. package/dist/createServer.js +42 -0
  3. package/dist/docs/architecture.md +19 -0
  4. package/dist/docs/extension.md +20 -0
  5. package/dist/docs/features.md +23 -0
  6. package/dist/docs/how-it-works.md +22 -0
  7. package/dist/docs/instructions.md +16 -0
  8. package/dist/docs/startup.md +20 -0
  9. package/dist/docs/structure.md +21 -0
  10. package/dist/index.js +10 -0
  11. package/dist/prompts/args.js +19 -0
  12. package/dist/prompts/completions.js +32 -0
  13. package/dist/prompts/index.js +19 -0
  14. package/dist/prompts/resource.js +35 -0
  15. package/dist/prompts/simple.js +16 -0
  16. package/dist/resources/docsDir.js +18 -0
  17. package/dist/resources/file-resources.js +52 -0
  18. package/dist/resources/index.js +24 -0
  19. package/dist/resources/session.js +34 -0
  20. package/dist/resources/subscriptions.js +38 -0
  21. package/dist/resources/templates.js +91 -0
  22. package/dist/server/logging.js +45 -0
  23. package/dist/server/roots.js +44 -0
  24. package/dist/tools/add.js +12 -0
  25. package/dist/tools/annotated-message.js +67 -0
  26. package/dist/tools/echo.js +12 -0
  27. package/dist/tools/get-resource-links.js +36 -0
  28. package/dist/tools/get-resource-reference.js +32 -0
  29. package/dist/tools/get-roots-list.js +51 -0
  30. package/dist/tools/get-structured-content.js +35 -0
  31. package/dist/tools/get-tiny-image.js +23 -0
  32. package/dist/tools/gzip-file-as-resource.js +115 -0
  33. package/dist/tools/index.js +63 -0
  34. package/dist/tools/print-env.js +10 -0
  35. package/dist/tools/simulate-research-query.js +173 -0
  36. package/dist/tools/toggle-simulated-logging.js +33 -0
  37. package/dist/tools/toggle-subscriber-updates.js +33 -0
  38. package/dist/tools/trigger-elicitation-request-async.js +136 -0
  39. package/dist/tools/trigger-elicitation-request.js +167 -0
  40. package/dist/tools/trigger-long-running-operation.js +36 -0
  41. package/dist/tools/trigger-sampling-request-async.js +112 -0
  42. package/dist/tools/trigger-sampling-request.js +39 -0
  43. package/dist/tools/trigger-url-elicitation.js +0 -0
  44. package/package.json +36 -0
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerTriggerSamplingRequestAsync = registerTriggerSamplingRequestAsync;
4
+ const zod_1 = require("zod");
5
+ const POLL_INTERVAL = 1000;
6
+ const MAX_POLL_ATTEMPTS = 60;
7
+ function registerTriggerSamplingRequestAsync(server) {
8
+ // Called from server.server.oninitialized (see index.ts), so the client's
9
+ // capabilities are already known here — this is not a registration-time
10
+ // race like it would be if called eagerly at server construction.
11
+ const clientCapabilities = server.server.getClientCapabilities() ?? {};
12
+ if (clientCapabilities.sampling === undefined)
13
+ return;
14
+ server.registerTool('trigger-sampling-request-async', {
15
+ description: 'Trigger an async sampling request that the CLIENT executes as a background task. ' +
16
+ 'Demonstrates bidirectional MCP tasks where the server sends a request and the client ' +
17
+ 'executes it asynchronously, allowing the server to poll for progress and results. ' +
18
+ 'Falls back gracefully if the client only supports synchronous sampling. Demo/test fixture.',
19
+ inputSchema: {
20
+ prompt: zod_1.z.string().describe('The prompt to send to the LLM'),
21
+ maxTokens: zod_1.z.number().default(100).describe('Maximum number of tokens to generate')
22
+ },
23
+ annotations: {
24
+ readOnlyHint: false,
25
+ destructiveHint: false,
26
+ idempotentHint: false,
27
+ openWorldHint: true
28
+ }
29
+ }, async ({ prompt, maxTokens }, extra) => {
30
+ const samplingResponse = await extra.sendRequest({
31
+ method: 'sampling/createMessage',
32
+ params: {
33
+ task: { ttl: 300000 },
34
+ messages: [{ role: 'user', content: { type: 'text', text: prompt } }],
35
+ systemPrompt: 'You are a helpful test server.',
36
+ maxTokens,
37
+ temperature: 0.7
38
+ }
39
+ }, zod_1.z.union([
40
+ zod_1.z.object({
41
+ task: zod_1.z.object({
42
+ taskId: zod_1.z.string(),
43
+ status: zod_1.z.string(),
44
+ pollInterval: zod_1.z.number().optional(),
45
+ statusMessage: zod_1.z.string().optional()
46
+ })
47
+ }),
48
+ zod_1.z.object({
49
+ role: zod_1.z.string(),
50
+ content: zod_1.z.any(),
51
+ model: zod_1.z.string(),
52
+ stopReason: zod_1.z.string().optional()
53
+ })
54
+ ]));
55
+ const isTaskResult = 'task' in samplingResponse && samplingResponse.task;
56
+ if (!isTaskResult) {
57
+ return {
58
+ content: [
59
+ {
60
+ type: 'text',
61
+ text: `[SYNC] Client executed synchronously:\n${JSON.stringify(samplingResponse, null, 2)}`
62
+ }
63
+ ]
64
+ };
65
+ }
66
+ const taskId = samplingResponse.task.taskId;
67
+ const statusMessages = [`Task created: ${taskId}`];
68
+ let attempts = 0;
69
+ let taskStatus = samplingResponse.task.status;
70
+ let taskStatusMessage;
71
+ while (taskStatus !== 'completed' &&
72
+ taskStatus !== 'failed' &&
73
+ taskStatus !== 'cancelled' &&
74
+ attempts < MAX_POLL_ATTEMPTS) {
75
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL));
76
+ attempts++;
77
+ const pollResult = await extra.sendRequest({ method: 'tasks/get', params: { taskId } }, zod_1.z.looseObject({ status: zod_1.z.string(), statusMessage: zod_1.z.string().optional() }));
78
+ taskStatus = pollResult.status;
79
+ taskStatusMessage = pollResult.statusMessage;
80
+ statusMessages.push(`Poll ${attempts}: ${taskStatus}${taskStatusMessage ? ` - ${taskStatusMessage}` : ''}`);
81
+ }
82
+ if (attempts >= MAX_POLL_ATTEMPTS) {
83
+ return {
84
+ content: [
85
+ {
86
+ type: 'text',
87
+ text: `[TIMEOUT] Task timed out after ${MAX_POLL_ATTEMPTS} poll attempts\n\nProgress:\n${statusMessages.join('\n')}`
88
+ }
89
+ ]
90
+ };
91
+ }
92
+ if (taskStatus === 'failed' || taskStatus === 'cancelled') {
93
+ return {
94
+ content: [
95
+ {
96
+ type: 'text',
97
+ text: `[${taskStatus.toUpperCase()}] ${taskStatusMessage || 'No message'}\n\nProgress:\n${statusMessages.join('\n')}`
98
+ }
99
+ ]
100
+ };
101
+ }
102
+ const result = await extra.sendRequest({ method: 'tasks/result', params: { taskId } }, zod_1.z.any());
103
+ return {
104
+ content: [
105
+ {
106
+ type: 'text',
107
+ text: `[COMPLETED] Async sampling completed!\n\n**Progress:**\n${statusMessages.join('\n')}\n\n**Result:**\n${JSON.stringify(result, null, 2)}`
108
+ }
109
+ ]
110
+ };
111
+ });
112
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerTriggerSamplingRequest = registerTriggerSamplingRequest;
4
+ const zod_1 = require("zod");
5
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
6
+ function registerTriggerSamplingRequest(server) {
7
+ // Called from server.server.oninitialized (see index.ts), so the client's
8
+ // capabilities are already known here — this is not a registration-time
9
+ // race like it would be if called eagerly at server construction.
10
+ const clientCapabilities = server.server.getClientCapabilities() ?? {};
11
+ if (clientCapabilities.sampling === undefined)
12
+ return;
13
+ server.registerTool('trigger-sampling-request', {
14
+ description: 'Trigger a request from the server for LLM sampling. Demo/test fixture.',
15
+ inputSchema: {
16
+ prompt: zod_1.z.string().describe('The prompt to send to the LLM'),
17
+ maxTokens: zod_1.z.number().default(100).describe('Maximum number of tokens to generate')
18
+ },
19
+ annotations: {
20
+ readOnlyHint: false,
21
+ destructiveHint: false,
22
+ idempotentHint: false,
23
+ openWorldHint: true
24
+ }
25
+ }, async ({ prompt, maxTokens }, extra) => {
26
+ const result = await extra.sendRequest({
27
+ method: 'sampling/createMessage',
28
+ params: {
29
+ messages: [{ role: 'user', content: { type: 'text', text: prompt } }],
30
+ systemPrompt: 'You are a helpful test server.',
31
+ maxTokens,
32
+ temperature: 0.7
33
+ }
34
+ }, types_js_1.CreateMessageResultSchema);
35
+ return {
36
+ content: [{ type: 'text', text: `LLM sampling result: \n${JSON.stringify(result, null, 2)}` }]
37
+ };
38
+ });
39
+ }
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@mcpflo/server-everything",
3
+ "version": "0.0.1",
4
+ "description": "Deterministic MCP test-fixture server for MCPFlo",
5
+ "mcpName": "io.github.harshalslimaye/mcpflo-server-everything",
6
+ "license": "MIT",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/harshalslimaye/mcpflo.git",
13
+ "directory": "packages/server-everything"
14
+ },
15
+ "type": "commonjs",
16
+ "main": "./dist/index.js",
17
+ "bin": {
18
+ "mcpflo-server-everything": "dist/index.js"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsc -p tsconfig.json && node -e \"require('fs').cpSync('docs','dist/docs',{recursive:true})\"",
25
+ "start": "node dist/index.js",
26
+ "test": "vitest run"
27
+ },
28
+ "dependencies": {
29
+ "@modelcontextprotocol/sdk": "1.29.0",
30
+ "zod": "^4.4.3"
31
+ },
32
+ "devDependencies": {
33
+ "typescript": "5.9.3",
34
+ "vitest": "4.1.8"
35
+ }
36
+ }