tunc-mcp 0.1.0 → 0.1.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/LICENSE +21 -0
- package/README.md +39 -0
- package/package.json +1 -1
- package/src/client.js +9 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TUNC LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -45,6 +45,45 @@ npm install tunc-mcp
|
|
|
45
45
|
Node 18 or newer. No dependencies. Get an API key at
|
|
46
46
|
<https://tunchub.com/account/keys/new> — you can scope it read-only.
|
|
47
47
|
|
|
48
|
+
## Options
|
|
49
|
+
|
|
50
|
+
Every helper takes an object. Only the key is required, and it falls back to `TUNC_API_KEY`.
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import { orb, art, doc, connect, SERVERS } from 'tunc-mcp';
|
|
54
|
+
|
|
55
|
+
const memory = orb({
|
|
56
|
+
apiKey: process.env.TUNC_API_KEY,
|
|
57
|
+
endpoint: 'https://mcp.tuncorb.com/mcp', // override: staging, a proxy, or a local mock
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- `apiKey` — defaults to `TUNC_API_KEY`. It is checked when the client is constructed, so a missing key fails immediately rather than on the first call.
|
|
62
|
+
- `endpoint` — replaces the built-in URL for that service. This is what you use to point the client at a test server.
|
|
63
|
+
- `service` — `"orb"`, `"art"` or `"doc"`, if you construct `TuncMcpClient` directly instead of using `orb()` / `art()` / `doc()`.
|
|
64
|
+
|
|
65
|
+
`SERVERS` is the map of default endpoints. `connect(key)` returns all three clients at once.
|
|
66
|
+
|
|
67
|
+
## What comes back
|
|
68
|
+
|
|
69
|
+
`callTool()` returns the server's MCP result unchanged:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
{ content: [{ type: "text", text: "<json string>" }], structuredContent: { /* … */ }, isError: false }
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Confusingly, the same payload often appears twice — as `structuredContent` and again serialised into `content[0].text`. Use `structuredContent` when it is there. When you only want the text, `callText()` unwraps it for you:
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
const text = await memory.callText('data_read', { name: 'contacts/ada' });
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Tool names come from the server, not from this package. Call `listTools()` to see what a service actually offers before writing against it — the list is not hard-coded here and changes as the servers change.
|
|
82
|
+
|
|
83
|
+
## ESM only
|
|
84
|
+
|
|
85
|
+
This package is ESM. In a CommonJS project, either set `"type": "module"` in `package.json` or import it from an `.mjs` file. Otherwise Node fails with `SyntaxError: Cannot use import statement outside a module`.
|
|
86
|
+
|
|
48
87
|
## Use
|
|
49
88
|
|
|
50
89
|
```js
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -99,16 +99,21 @@ export class TuncMcpClient {
|
|
|
99
99
|
if (session) this.#sessionId = session;
|
|
100
100
|
|
|
101
101
|
const text = await response.text();
|
|
102
|
+
const body = parseBody(response.headers.get('content-type'), text);
|
|
102
103
|
|
|
103
104
|
if (response.status === 401) {
|
|
105
|
+
// The server knows why it refused: missing key, revoked, or wrong scope.
|
|
106
|
+
// Keep its words and add ours, rather than replacing a specific answer
|
|
107
|
+
// with a generic one.
|
|
108
|
+
const server = body?.error?.message;
|
|
104
109
|
throw new TuncMcpError(
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
server
|
|
111
|
+
? `${server} (the API key is missing, revoked, or not scoped for this service)`
|
|
112
|
+
: 'Unauthorized. The API key is missing, revoked, or not scoped for this service.',
|
|
113
|
+
{ status: 401, code: body?.error?.code, body },
|
|
107
114
|
);
|
|
108
115
|
}
|
|
109
116
|
|
|
110
|
-
const body = parseBody(response.headers.get('content-type'), text);
|
|
111
|
-
|
|
112
117
|
if (!response.ok) {
|
|
113
118
|
throw new TuncMcpError(body?.error?.message ?? `HTTP ${response.status}`, {
|
|
114
119
|
status: response.status,
|