@mappies/miniwat-mcp-core 0.0.0 → 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.
- package/README.md +45 -0
- package/package.json +7 -46
- package/LICENSE +0 -131
- package/dist/index.cjs +0 -85
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -25
- package/dist/index.d.ts +0 -25
- package/dist/index.js +0 -58
- package/dist/index.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @mappies/miniwat-mcp-core
|
|
2
|
+
|
|
3
|
+
## ⚠️ IMPORTANT NOTICE ⚠️
|
|
4
|
+
|
|
5
|
+
**This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
|
|
6
|
+
|
|
7
|
+
This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
|
|
11
|
+
This package exists to:
|
|
12
|
+
1. Configure OIDC trusted publishing for the package name `@mappies/miniwat-mcp-core`
|
|
13
|
+
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
+
3. Establish provenance for packages published under this name
|
|
15
|
+
|
|
16
|
+
## What is OIDC Trusted Publishing?
|
|
17
|
+
|
|
18
|
+
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
+
|
|
20
|
+
## Setup Instructions
|
|
21
|
+
|
|
22
|
+
To properly configure OIDC trusted publishing for this package:
|
|
23
|
+
|
|
24
|
+
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
+
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
+
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
+
4. Use the configured workflow to publish your actual package
|
|
28
|
+
|
|
29
|
+
## DO NOT USE THIS PACKAGE
|
|
30
|
+
|
|
31
|
+
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
+
- Contains no executable code
|
|
33
|
+
- Provides no functionality
|
|
34
|
+
- Should not be installed as a dependency
|
|
35
|
+
- Exists only for administrative purposes
|
|
36
|
+
|
|
37
|
+
## More Information
|
|
38
|
+
|
|
39
|
+
For more details about npm's trusted publishing feature, see:
|
|
40
|
+
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
+
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
**Maintained for OIDC setup purposes only**
|
package/package.json
CHANGED
|
@@ -1,49 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mappies/miniwat-mcp-core",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/mappies/miniwat-mcp-core.git"
|
|
12
|
-
},
|
|
13
|
-
"license": "PolyForm-Noncommercial-1.0.0",
|
|
14
|
-
"author": "Nithiwat Kampanya",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"test": "vitest run",
|
|
17
|
-
"test-watch": "vitest",
|
|
18
|
-
"build": "tsup"
|
|
19
|
-
},
|
|
20
|
-
"type": "module",
|
|
21
|
-
"main": "./dist/index.cjs",
|
|
22
|
-
"module": "./dist/index.js",
|
|
23
|
-
"types": "./dist/index.d.ts",
|
|
24
|
-
"exports": {
|
|
25
|
-
".": {
|
|
26
|
-
"import": {
|
|
27
|
-
"types": "./dist/index.d.ts",
|
|
28
|
-
"default": "./dist/index.js"
|
|
29
|
-
},
|
|
30
|
-
"require": {
|
|
31
|
-
"types": "./dist/index.d.cts",
|
|
32
|
-
"default": "./dist/index.cjs"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"files": [
|
|
37
|
-
"dist"
|
|
38
|
-
],
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/node": "^25.6.0",
|
|
41
|
-
"tsup": "^8.5.1",
|
|
42
|
-
"typescript": "^5.9.3",
|
|
43
|
-
"vitest": "^4.1.0"
|
|
44
|
-
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"@mappies/miniwat-api-core": "^0.2.0",
|
|
47
|
-
"openai": "^6.34.0"
|
|
48
|
-
}
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "OIDC trusted publishing setup package for @mappies/miniwat-mcp-core",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"oidc",
|
|
7
|
+
"trusted-publishing",
|
|
8
|
+
"setup"
|
|
9
|
+
]
|
|
49
10
|
}
|
package/LICENSE
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# PolyForm Noncommercial License 1.0.0
|
|
2
|
-
|
|
3
|
-
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
|
-
|
|
5
|
-
## Acceptance
|
|
6
|
-
|
|
7
|
-
In order to get any license under these terms, you must agree
|
|
8
|
-
to them as both strict obligations and conditions to all
|
|
9
|
-
your licenses.
|
|
10
|
-
|
|
11
|
-
## Copyright License
|
|
12
|
-
|
|
13
|
-
The licensor grants you a copyright license for the
|
|
14
|
-
software to do everything you might do with the software
|
|
15
|
-
that would otherwise infringe the licensor's copyright
|
|
16
|
-
in it for any permitted purpose. However, you may
|
|
17
|
-
only distribute the software according to [Distribution
|
|
18
|
-
License](#distribution-license) and make changes or new works
|
|
19
|
-
based on the software according to [Changes and New Works
|
|
20
|
-
License](#changes-and-new-works-license).
|
|
21
|
-
|
|
22
|
-
## Distribution License
|
|
23
|
-
|
|
24
|
-
The licensor grants you an additional copyright license
|
|
25
|
-
to distribute copies of the software. Your license
|
|
26
|
-
to distribute covers distributing the software with
|
|
27
|
-
changes and new works permitted by [Changes and New Works
|
|
28
|
-
License](#changes-and-new-works-license).
|
|
29
|
-
|
|
30
|
-
## Notices
|
|
31
|
-
|
|
32
|
-
You must ensure that anyone who gets a copy of any part of
|
|
33
|
-
the software from you also gets a copy of these terms or the
|
|
34
|
-
URL for them above, as well as copies of any plain-text lines
|
|
35
|
-
beginning with `Required Notice:` that the licensor provided
|
|
36
|
-
with the software. For example:
|
|
37
|
-
|
|
38
|
-
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
39
|
-
|
|
40
|
-
## Changes and New Works License
|
|
41
|
-
|
|
42
|
-
The licensor grants you an additional copyright license to
|
|
43
|
-
make changes and new works based on the software for any
|
|
44
|
-
permitted purpose.
|
|
45
|
-
|
|
46
|
-
## Patent License
|
|
47
|
-
|
|
48
|
-
The licensor grants you a patent license for the software that
|
|
49
|
-
covers patent claims the licensor can license, or becomes able
|
|
50
|
-
to license, that you would infringe by using the software.
|
|
51
|
-
|
|
52
|
-
## Noncommercial Purposes
|
|
53
|
-
|
|
54
|
-
Any noncommercial purpose is a permitted purpose.
|
|
55
|
-
|
|
56
|
-
## Personal Uses
|
|
57
|
-
|
|
58
|
-
Personal use for research, experiment, and testing for
|
|
59
|
-
the benefit of public knowledge, personal study, private
|
|
60
|
-
entertainment, hobby projects, amateur pursuits, or religious
|
|
61
|
-
observance, without any anticipated commercial application,
|
|
62
|
-
is use for a permitted purpose.
|
|
63
|
-
|
|
64
|
-
## Noncommercial Organizations
|
|
65
|
-
|
|
66
|
-
Use by any charitable organization, educational institution,
|
|
67
|
-
public research organization, public safety or health
|
|
68
|
-
organization, environmental protection organization,
|
|
69
|
-
or government institution is use for a permitted purpose
|
|
70
|
-
regardless of the source of funding or obligations resulting
|
|
71
|
-
from the funding.
|
|
72
|
-
|
|
73
|
-
## Fair Use
|
|
74
|
-
|
|
75
|
-
You may have "fair use" rights for the software under the
|
|
76
|
-
law. These terms do not limit them.
|
|
77
|
-
|
|
78
|
-
## No Other Rights
|
|
79
|
-
|
|
80
|
-
These terms do not allow you to sublicense or transfer any of
|
|
81
|
-
your licenses to anyone else, or prevent the licensor from
|
|
82
|
-
granting licenses to anyone else. These terms do not imply
|
|
83
|
-
any other licenses.
|
|
84
|
-
|
|
85
|
-
## Patent Defense
|
|
86
|
-
|
|
87
|
-
If you make any written claim that the software infringes or
|
|
88
|
-
contributes to infringement of any patent, your patent license
|
|
89
|
-
for the software granted under these terms ends immediately. If
|
|
90
|
-
your company makes such a claim, your patent license ends
|
|
91
|
-
immediately for work on behalf of your company.
|
|
92
|
-
|
|
93
|
-
## Violations
|
|
94
|
-
|
|
95
|
-
The first time you are notified in writing that you have
|
|
96
|
-
violated any of these terms, or done anything with the software
|
|
97
|
-
not covered by your licenses, your licenses can nonetheless
|
|
98
|
-
continue if you come into full compliance with these terms,
|
|
99
|
-
and take practical steps to correct past violations, within
|
|
100
|
-
32 days of receiving notice. Otherwise, all your licenses
|
|
101
|
-
end immediately.
|
|
102
|
-
|
|
103
|
-
## No Liability
|
|
104
|
-
|
|
105
|
-
***As far as the law allows, the software comes as is, without
|
|
106
|
-
any warranty or condition, and the licensor will not be liable
|
|
107
|
-
to you for any damages arising out of these terms or the use
|
|
108
|
-
or nature of the software, under any kind of legal claim.***
|
|
109
|
-
|
|
110
|
-
## Definitions
|
|
111
|
-
|
|
112
|
-
The **licensor** is the individual or entity offering these
|
|
113
|
-
terms, and the **software** is the software the licensor makes
|
|
114
|
-
available under these terms.
|
|
115
|
-
|
|
116
|
-
**You** refers to the individual or entity agreeing to these
|
|
117
|
-
terms.
|
|
118
|
-
|
|
119
|
-
**Your company** is any legal entity, sole proprietorship,
|
|
120
|
-
or other kind of organization that you work for, plus all
|
|
121
|
-
organizations that have control over, are under the control of,
|
|
122
|
-
or are under common control with that organization. **Control**
|
|
123
|
-
means ownership of substantially all the assets of an entity,
|
|
124
|
-
or the power to direct its management and policies by vote,
|
|
125
|
-
contract, or otherwise. Control can be direct or indirect.
|
|
126
|
-
|
|
127
|
-
**Your licenses** are all the licenses granted to you for the
|
|
128
|
-
software under these terms.
|
|
129
|
-
|
|
130
|
-
**Use** means anything you do with the software requiring one
|
|
131
|
-
of your licenses.
|
package/dist/index.cjs
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
ToolDispatcher: () => ToolDispatcher
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
|
|
27
|
-
// src/entities/toolDispatcher.ts
|
|
28
|
-
var import_miniwat_api_core = require("@mappies/miniwat-api-core");
|
|
29
|
-
var ToolDispatcher = class {
|
|
30
|
-
constructor(mcp) {
|
|
31
|
-
this.mcp = mcp;
|
|
32
|
-
this.tools = [];
|
|
33
|
-
}
|
|
34
|
-
async init() {
|
|
35
|
-
if (this.tools !== void 0) return;
|
|
36
|
-
this.tools = [];
|
|
37
|
-
for (let server of Object.keys(this.mcp.mcpServers)) {
|
|
38
|
-
let service = this.mcp.mcpServers[server];
|
|
39
|
-
const pck = await import(service.package);
|
|
40
|
-
for (let t of service.tools) {
|
|
41
|
-
let definition = pck[t.import];
|
|
42
|
-
let tool = new import_miniwat_api_core.Tool({
|
|
43
|
-
name: definition.name,
|
|
44
|
-
description: definition.description,
|
|
45
|
-
schema: definition.inputSchema,
|
|
46
|
-
func: pck[definition.name],
|
|
47
|
-
getInputText: pck[`${definition.name}InputText`]
|
|
48
|
-
});
|
|
49
|
-
this.tools.push(tool);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
async list() {
|
|
54
|
-
await this.init();
|
|
55
|
-
return this.tools;
|
|
56
|
-
}
|
|
57
|
-
async get(name) {
|
|
58
|
-
await this.init();
|
|
59
|
-
return this.tools.find((tool) => tool.name === name);
|
|
60
|
-
}
|
|
61
|
-
async getInputText(name, input) {
|
|
62
|
-
const tool = await this.get(name);
|
|
63
|
-
return tool?.getInputText?.(input) || "";
|
|
64
|
-
}
|
|
65
|
-
async execute(name, input) {
|
|
66
|
-
const tool = await this.get(name);
|
|
67
|
-
if (!tool) {
|
|
68
|
-
throw new Error(`Tool ${name} could not be found.`);
|
|
69
|
-
}
|
|
70
|
-
if (!tool.func) {
|
|
71
|
-
throw new Error(`Tool ${name} does not have a function.`);
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
let result = await tool.func(input);
|
|
75
|
-
return result;
|
|
76
|
-
} catch (e) {
|
|
77
|
-
throw new Error(`Failed to run ${name} tool: ${e?.message}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
-
0 && (module.exports = {
|
|
83
|
-
ToolDispatcher
|
|
84
|
-
});
|
|
85
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/entities/toolDispatcher.ts"],"sourcesContent":["export { ToolDispatcher } from './entities/toolDispatcher';\nexport { McpConfig, McpServer, McpToolImport } from './interfaces/mcpConfig';","import { Tool } from \"@mappies/miniwat-api-core\";\nimport { McpConfig } from \"../interfaces/mcpConfig\";\n\nexport class ToolDispatcher\n{\n private tools:Tool[]\n \n constructor(private mcp:McpConfig)\n {\n this.tools = []\n }\n\n async init()\n {\n if(this.tools !== undefined) return;\n\n this.tools = [];\n\n for(let server of Object.keys(this.mcp.mcpServers))\n {\n let service = this.mcp.mcpServers[server]\n \n const pck = await import(service.package);\n for(let t of service.tools)\n {\n let definition = pck[t.import];\n let tool = new Tool({ \n name: definition.name, \n description: definition.description, \n schema: definition.inputSchema, \n func: pck[definition.name],\n getInputText: pck[`${definition.name}InputText`]\n })\n \n this.tools.push(tool)\n }\n }\n }\n\n async list(): Promise<Tool[]>\n {\n await this.init()\n return this.tools;\n }\n\n async get(name:string): Promise<Tool|undefined>\n {\n await this.init()\n return this.tools.find(tool => tool.name === name);\n }\n\n async getInputText(name:string, input?:object): Promise<string>\n {\n const tool = await this.get(name);\n\n return tool?.getInputText?.(input) || '';\n }\n\n async execute(name:string, input?:object): Promise<string>\n {\n const tool = await this.get(name);\n \n if(!tool)\n {\n throw new Error(`Tool ${name} could not be found.`);\n }\n\n if(!tool.func)\n {\n throw new Error(`Tool ${name} does not have a function.`);\n }\n\n try\n {\n let result = await tool.func(input);\n return result;\n }\n catch(e:any)\n {\n throw new Error(`Failed to run ${name} tool: ${e?.message}`);\n }\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,8BAAqB;AAGd,IAAM,iBAAN,MACP;AAAA,EAGI,YAAoB,KACpB;AADoB;AAEhB,SAAK,QAAQ,CAAC;AAAA,EAClB;AAAA,EAEA,MAAM,OACN;AACI,QAAG,KAAK,UAAU,OAAW;AAE7B,SAAK,QA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","names":[]}
|
package/dist/index.d.cts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Tool } from '@mappies/miniwat-api-core';
|
|
2
|
-
|
|
3
|
-
interface McpConfig {
|
|
4
|
-
mcpServers: Record<string, McpServer>;
|
|
5
|
-
}
|
|
6
|
-
interface McpServer {
|
|
7
|
-
package: string;
|
|
8
|
-
tools: McpToolImport[];
|
|
9
|
-
}
|
|
10
|
-
interface McpToolImport {
|
|
11
|
-
import: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare class ToolDispatcher {
|
|
15
|
-
private mcp;
|
|
16
|
-
private tools;
|
|
17
|
-
constructor(mcp: McpConfig);
|
|
18
|
-
init(): Promise<void>;
|
|
19
|
-
list(): Promise<Tool[]>;
|
|
20
|
-
get(name: string): Promise<Tool | undefined>;
|
|
21
|
-
getInputText(name: string, input?: object): Promise<string>;
|
|
22
|
-
execute(name: string, input?: object): Promise<string>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { type McpConfig, type McpServer, type McpToolImport, ToolDispatcher };
|
package/dist/index.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Tool } from '@mappies/miniwat-api-core';
|
|
2
|
-
|
|
3
|
-
interface McpConfig {
|
|
4
|
-
mcpServers: Record<string, McpServer>;
|
|
5
|
-
}
|
|
6
|
-
interface McpServer {
|
|
7
|
-
package: string;
|
|
8
|
-
tools: McpToolImport[];
|
|
9
|
-
}
|
|
10
|
-
interface McpToolImport {
|
|
11
|
-
import: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare class ToolDispatcher {
|
|
15
|
-
private mcp;
|
|
16
|
-
private tools;
|
|
17
|
-
constructor(mcp: McpConfig);
|
|
18
|
-
init(): Promise<void>;
|
|
19
|
-
list(): Promise<Tool[]>;
|
|
20
|
-
get(name: string): Promise<Tool | undefined>;
|
|
21
|
-
getInputText(name: string, input?: object): Promise<string>;
|
|
22
|
-
execute(name: string, input?: object): Promise<string>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { type McpConfig, type McpServer, type McpToolImport, ToolDispatcher };
|
package/dist/index.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// src/entities/toolDispatcher.ts
|
|
2
|
-
import { Tool } from "@mappies/miniwat-api-core";
|
|
3
|
-
var ToolDispatcher = class {
|
|
4
|
-
constructor(mcp) {
|
|
5
|
-
this.mcp = mcp;
|
|
6
|
-
this.tools = [];
|
|
7
|
-
}
|
|
8
|
-
async init() {
|
|
9
|
-
if (this.tools !== void 0) return;
|
|
10
|
-
this.tools = [];
|
|
11
|
-
for (let server of Object.keys(this.mcp.mcpServers)) {
|
|
12
|
-
let service = this.mcp.mcpServers[server];
|
|
13
|
-
const pck = await import(service.package);
|
|
14
|
-
for (let t of service.tools) {
|
|
15
|
-
let definition = pck[t.import];
|
|
16
|
-
let tool = new Tool({
|
|
17
|
-
name: definition.name,
|
|
18
|
-
description: definition.description,
|
|
19
|
-
schema: definition.inputSchema,
|
|
20
|
-
func: pck[definition.name],
|
|
21
|
-
getInputText: pck[`${definition.name}InputText`]
|
|
22
|
-
});
|
|
23
|
-
this.tools.push(tool);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async list() {
|
|
28
|
-
await this.init();
|
|
29
|
-
return this.tools;
|
|
30
|
-
}
|
|
31
|
-
async get(name) {
|
|
32
|
-
await this.init();
|
|
33
|
-
return this.tools.find((tool) => tool.name === name);
|
|
34
|
-
}
|
|
35
|
-
async getInputText(name, input) {
|
|
36
|
-
const tool = await this.get(name);
|
|
37
|
-
return tool?.getInputText?.(input) || "";
|
|
38
|
-
}
|
|
39
|
-
async execute(name, input) {
|
|
40
|
-
const tool = await this.get(name);
|
|
41
|
-
if (!tool) {
|
|
42
|
-
throw new Error(`Tool ${name} could not be found.`);
|
|
43
|
-
}
|
|
44
|
-
if (!tool.func) {
|
|
45
|
-
throw new Error(`Tool ${name} does not have a function.`);
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
let result = await tool.func(input);
|
|
49
|
-
return result;
|
|
50
|
-
} catch (e) {
|
|
51
|
-
throw new Error(`Failed to run ${name} tool: ${e?.message}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
export {
|
|
56
|
-
ToolDispatcher
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/entities/toolDispatcher.ts"],"sourcesContent":["import { Tool } from \"@mappies/miniwat-api-core\";\nimport { McpConfig } from \"../interfaces/mcpConfig\";\n\nexport class ToolDispatcher\n{\n private tools:Tool[]\n \n constructor(private mcp:McpConfig)\n {\n this.tools = []\n }\n\n async init()\n {\n if(this.tools !== undefined) return;\n\n this.tools = [];\n\n for(let server of Object.keys(this.mcp.mcpServers))\n {\n let service = this.mcp.mcpServers[server]\n \n const pck = await import(service.package);\n for(let t of service.tools)\n {\n let definition = pck[t.import];\n let tool = new Tool({ \n name: definition.name, \n description: definition.description, \n schema: definition.inputSchema, \n func: pck[definition.name],\n getInputText: pck[`${definition.name}InputText`]\n })\n \n this.tools.push(tool)\n }\n }\n }\n\n async list(): Promise<Tool[]>\n {\n await this.init()\n return this.tools;\n }\n\n async get(name:string): Promise<Tool|undefined>\n {\n await this.init()\n return this.tools.find(tool => tool.name === name);\n }\n\n async getInputText(name:string, input?:object): Promise<string>\n {\n const tool = await this.get(name);\n\n return tool?.getInputText?.(input) || '';\n }\n\n async execute(name:string, input?:object): Promise<string>\n {\n const tool = await this.get(name);\n \n if(!tool)\n {\n throw new Error(`Tool ${name} could not be found.`);\n }\n\n if(!tool.func)\n {\n throw new Error(`Tool ${name} does not have a function.`);\n }\n\n try\n {\n let result = await tool.func(input);\n return result;\n }\n catch(e:any)\n {\n throw new Error(`Failed to run ${name} tool: ${e?.message}`);\n }\n }\n}"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