@openmrp/sdk-mcp 0.19.4 → 0.19.6
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/code-tool-worker.js +4 -4
- package/code-tool-worker.mjs +5 -5
- package/package.json +3 -3
- package/server.js +1 -1
- package/server.mjs +3 -3
- package/src/code-tool-worker.ts +5 -5
- package/src/server.ts +6 -6
- package/src/types.ts +2 -2
- package/types.d.mts +2 -2
- package/types.d.ts +2 -2
package/code-tool-worker.js
CHANGED
|
@@ -81,10 +81,10 @@ function getRunFunctionSource(code) {
|
|
|
81
81
|
function getTSDiagnostics(code) {
|
|
82
82
|
const functionSource = getRunFunctionSource(code);
|
|
83
83
|
const codeWithImport = [
|
|
84
|
-
'import {
|
|
84
|
+
'import { OpenMRP } from "@openmrp/sdk";',
|
|
85
85
|
functionSource.type === 'declaration' ?
|
|
86
|
-
`async function run(${functionSource.client}:
|
|
87
|
-
: `const run: (${functionSource.client}:
|
|
86
|
+
`async function run(${functionSource.client}: OpenMRP)`
|
|
87
|
+
: `const run: (${functionSource.client}: OpenMRP) => Promise<unknown> =`,
|
|
88
88
|
functionSource.code,
|
|
89
89
|
].join('\n');
|
|
90
90
|
const sourcePath = node_path_1.default.resolve('code.ts');
|
|
@@ -594,7 +594,7 @@ const fetch = async (req) => {
|
|
|
594
594
|
err_lines: [],
|
|
595
595
|
}, { status: 400, statusText: 'Code execution error' });
|
|
596
596
|
}
|
|
597
|
-
const client = new sdk_1.
|
|
597
|
+
const client = new sdk_1.OpenMRP({
|
|
598
598
|
...opts,
|
|
599
599
|
});
|
|
600
600
|
const log_lines = [];
|
package/code-tool-worker.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import util from 'node:util';
|
|
4
4
|
import Fuse from 'fuse.js';
|
|
5
5
|
import ts from 'typescript';
|
|
6
|
-
import {
|
|
6
|
+
import { OpenMRP } from '@openmrp/sdk';
|
|
7
7
|
async function tseval(code) {
|
|
8
8
|
return import('data:application/typescript;charset=utf-8;base64,' + Buffer.from(code).toString('base64'));
|
|
9
9
|
}
|
|
@@ -43,10 +43,10 @@ function getRunFunctionSource(code) {
|
|
|
43
43
|
function getTSDiagnostics(code) {
|
|
44
44
|
const functionSource = getRunFunctionSource(code);
|
|
45
45
|
const codeWithImport = [
|
|
46
|
-
'import {
|
|
46
|
+
'import { OpenMRP } from "@openmrp/sdk";',
|
|
47
47
|
functionSource.type === 'declaration' ?
|
|
48
|
-
`async function run(${functionSource.client}:
|
|
49
|
-
: `const run: (${functionSource.client}:
|
|
48
|
+
`async function run(${functionSource.client}: OpenMRP)`
|
|
49
|
+
: `const run: (${functionSource.client}: OpenMRP) => Promise<unknown> =`,
|
|
50
50
|
functionSource.code,
|
|
51
51
|
].join('\n');
|
|
52
52
|
const sourcePath = path.resolve('code.ts');
|
|
@@ -556,7 +556,7 @@ const fetch = async (req) => {
|
|
|
556
556
|
err_lines: [],
|
|
557
557
|
}, { status: 400, statusText: 'Code execution error' });
|
|
558
558
|
}
|
|
559
|
-
const client = new
|
|
559
|
+
const client = new OpenMRP({
|
|
560
560
|
...opts,
|
|
561
561
|
});
|
|
562
562
|
const log_lines = [];
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrp/sdk-mcp",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.6",
|
|
4
4
|
"description": "The official MCP Server for the Openmrp API",
|
|
5
|
-
"author": "Openmrp <support@
|
|
5
|
+
"author": "Openmrp <support@openmrp.ai>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"type": "commonjs",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"fix": "eslint --fix ."
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@openmrp/sdk": "^0.19.
|
|
30
|
+
"@openmrp/sdk": "^0.19.6",
|
|
31
31
|
"ajv": "^8.18.0",
|
|
32
32
|
"@cloudflare/cabidela": "^0.2.4",
|
|
33
33
|
"@hono/node-server": "^1.19.10",
|
package/server.js
CHANGED
|
@@ -17,7 +17,7 @@ const methods_1 = require("./methods.js");
|
|
|
17
17
|
const util_1 = require("./util.js");
|
|
18
18
|
const newMcpServer = async ({ stainlessApiKey, customInstructionsPath, }) => new mcp_js_1.McpServer({
|
|
19
19
|
name: 'openmrp_sdk_api',
|
|
20
|
-
version: '0.19.
|
|
20
|
+
version: '0.19.5',
|
|
21
21
|
}, {
|
|
22
22
|
instructions: await (0, instructions_1.getInstructions)({ stainlessApiKey, customInstructionsPath }),
|
|
23
23
|
capabilities: { tools: {}, logging: {} },
|
package/server.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { CallToolRequestSchema, ListToolsRequestSchema, SetLevelRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
-
import
|
|
4
|
+
import OpenMRP from '@openmrp/sdk';
|
|
5
5
|
import { codeTool } from "./code-tool.mjs";
|
|
6
6
|
import { getInstructions } from "./instructions.mjs";
|
|
7
7
|
import { blockedMethodsForCodeTool } from "./methods.mjs";
|
|
8
8
|
import { readEnv } from "./util.mjs";
|
|
9
9
|
export const newMcpServer = async ({ stainlessApiKey, customInstructionsPath, }) => new McpServer({
|
|
10
10
|
name: 'openmrp_sdk_api',
|
|
11
|
-
version: '0.19.
|
|
11
|
+
version: '0.19.5',
|
|
12
12
|
}, {
|
|
13
13
|
instructions: await getInstructions({ stainlessApiKey, customInstructionsPath }),
|
|
14
14
|
capabilities: { tools: {}, logging: {} },
|
|
@@ -39,7 +39,7 @@ export async function initMcpServer(params) {
|
|
|
39
39
|
throw _clientError;
|
|
40
40
|
if (!_client) {
|
|
41
41
|
try {
|
|
42
|
-
_client = new
|
|
42
|
+
_client = new OpenMRP({
|
|
43
43
|
...{
|
|
44
44
|
openmrpAccountID: readEnv('OPENMRP_OPENMRP_ACCOUNT_ID'),
|
|
45
45
|
environment: (readEnv('OPENMRP_ENVIRONMENT') || undefined),
|
package/src/code-tool-worker.ts
CHANGED
|
@@ -5,7 +5,7 @@ import util from 'node:util';
|
|
|
5
5
|
import Fuse from 'fuse.js';
|
|
6
6
|
import ts from 'typescript';
|
|
7
7
|
import { WorkerOutput } from './code-tool-types';
|
|
8
|
-
import {
|
|
8
|
+
import { OpenMRP, ClientOptions } from '@openmrp/sdk';
|
|
9
9
|
|
|
10
10
|
async function tseval(code: string) {
|
|
11
11
|
return import('data:application/typescript;charset=utf-8;base64,' + Buffer.from(code).toString('base64'));
|
|
@@ -57,10 +57,10 @@ function getRunFunctionSource(code: string): {
|
|
|
57
57
|
function getTSDiagnostics(code: string): string[] {
|
|
58
58
|
const functionSource = getRunFunctionSource(code)!;
|
|
59
59
|
const codeWithImport = [
|
|
60
|
-
'import {
|
|
60
|
+
'import { OpenMRP } from "@openmrp/sdk";',
|
|
61
61
|
functionSource.type === 'declaration' ?
|
|
62
|
-
`async function run(${functionSource.client}:
|
|
63
|
-
: `const run: (${functionSource.client}:
|
|
62
|
+
`async function run(${functionSource.client}: OpenMRP)`
|
|
63
|
+
: `const run: (${functionSource.client}: OpenMRP) => Promise<unknown> =`,
|
|
64
64
|
functionSource.code,
|
|
65
65
|
].join('\n');
|
|
66
66
|
const sourcePath = path.resolve('code.ts');
|
|
@@ -605,7 +605,7 @@ const fetch = async (req: Request): Promise<Response> => {
|
|
|
605
605
|
);
|
|
606
606
|
}
|
|
607
607
|
|
|
608
|
-
const client = new
|
|
608
|
+
const client = new OpenMRP({
|
|
609
609
|
...opts,
|
|
610
610
|
});
|
|
611
611
|
|
package/src/server.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
SetLevelRequestSchema,
|
|
9
9
|
} from '@modelcontextprotocol/sdk/types.js';
|
|
10
10
|
import { ClientOptions } from '@openmrp/sdk';
|
|
11
|
-
import
|
|
11
|
+
import OpenMRP from '@openmrp/sdk';
|
|
12
12
|
import { codeTool } from './code-tool';
|
|
13
13
|
import { getInstructions } from './instructions';
|
|
14
14
|
import { McpOptions } from './options';
|
|
@@ -26,7 +26,7 @@ export const newMcpServer = async ({
|
|
|
26
26
|
new McpServer(
|
|
27
27
|
{
|
|
28
28
|
name: 'openmrp_sdk_api',
|
|
29
|
-
version: '0.19.
|
|
29
|
+
version: '0.19.5',
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
instructions: await getInstructions({ stainlessApiKey, customInstructionsPath }),
|
|
@@ -64,15 +64,15 @@ export async function initMcpServer(params: {
|
|
|
64
64
|
error: logAtLevel('error'),
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
let _client:
|
|
67
|
+
let _client: OpenMRP | undefined;
|
|
68
68
|
let _clientError: Error | undefined;
|
|
69
69
|
let _logLevel: 'debug' | 'info' | 'warn' | 'error' | 'off' | undefined;
|
|
70
70
|
|
|
71
|
-
const getClient = ():
|
|
71
|
+
const getClient = (): OpenMRP => {
|
|
72
72
|
if (_clientError) throw _clientError;
|
|
73
73
|
if (!_client) {
|
|
74
74
|
try {
|
|
75
|
-
_client = new
|
|
75
|
+
_client = new OpenMRP({
|
|
76
76
|
...{
|
|
77
77
|
openmrpAccountID: readEnv('OPENMRP_OPENMRP_ACCOUNT_ID'),
|
|
78
78
|
environment: (readEnv('OPENMRP_ENVIRONMENT') || undefined) as any,
|
|
@@ -111,7 +111,7 @@ export async function initMcpServer(params: {
|
|
|
111
111
|
throw new Error(`Unknown tool: ${name}`);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
let client:
|
|
114
|
+
let client: OpenMRP;
|
|
115
115
|
try {
|
|
116
116
|
client = getClient();
|
|
117
117
|
} catch (error) {
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import OpenMRP from '@openmrp/sdk';
|
|
4
4
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
|
|
6
6
|
type TextContentBlock = {
|
|
@@ -43,7 +43,7 @@ export type ToolCallResult = {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
export type McpRequestContext = {
|
|
46
|
-
client:
|
|
46
|
+
client: OpenMRP;
|
|
47
47
|
stainlessApiKey?: string | undefined;
|
|
48
48
|
upstreamClientEnvs?: Record<string, string> | undefined;
|
|
49
49
|
mcpSessionId?: string | undefined;
|
package/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import OpenMRP from '@openmrp/sdk';
|
|
2
2
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
type TextContentBlock = {
|
|
4
4
|
type: 'text';
|
|
@@ -32,7 +32,7 @@ export type ToolCallResult = {
|
|
|
32
32
|
isError?: boolean;
|
|
33
33
|
};
|
|
34
34
|
export type McpRequestContext = {
|
|
35
|
-
client:
|
|
35
|
+
client: OpenMRP;
|
|
36
36
|
stainlessApiKey?: string | undefined;
|
|
37
37
|
upstreamClientEnvs?: Record<string, string> | undefined;
|
|
38
38
|
mcpSessionId?: string | undefined;
|
package/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import OpenMRP from '@openmrp/sdk';
|
|
2
2
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
type TextContentBlock = {
|
|
4
4
|
type: 'text';
|
|
@@ -32,7 +32,7 @@ export type ToolCallResult = {
|
|
|
32
32
|
isError?: boolean;
|
|
33
33
|
};
|
|
34
34
|
export type McpRequestContext = {
|
|
35
|
-
client:
|
|
35
|
+
client: OpenMRP;
|
|
36
36
|
stainlessApiKey?: string | undefined;
|
|
37
37
|
upstreamClientEnvs?: Record<string, string> | undefined;
|
|
38
38
|
mcpSessionId?: string | undefined;
|