Skip to content

Commit a325ceb

Browse files
chore: configure new SDK language
1 parent fb84cfe commit a325ceb

File tree

283 files changed

+2793
-1739
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+2793
-1739
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Set up Node
2525
uses: actions/setup-node@v4
2626
with:
27-
node-version: '20'
27+
node-version: '22'
2828

2929
- name: Bootstrap
3030
run: ./scripts/bootstrap
@@ -46,7 +46,7 @@ jobs:
4646
- name: Set up Node
4747
uses: actions/setup-node@v4
4848
with:
49-
node-version: '20'
49+
node-version: '22'
5050

5151
- name: Bootstrap
5252
run: ./scripts/bootstrap
@@ -68,6 +68,15 @@ jobs:
6868
AUTH: ${{ steps.github-oidc.outputs.github_token }}
6969
SHA: ${{ github.sha }}
7070
run: ./scripts/utils/upload-artifact.sh
71+
72+
- name: Upload MCP Server tarball
73+
if: github.repository == 'stainless-sdks/hanzo-ai-typescript'
74+
env:
75+
URL: https://pkg.stainless.com/s?subpackage=mcp-server
76+
AUTH: ${{ steps.github-oidc.outputs.github_token }}
77+
SHA: ${{ github.sha }}
78+
BASE_PATH: packages/mcp-server
79+
run: ./scripts/utils/upload-artifact.sh
7180
test:
7281
timeout-minutes: 10
7382
name: test

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ dist
77
dist-deno
88
/*.tgz
99
.idea/
10-
10+
dist-bundle
11+
*.dxt

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 188
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-2d6e1036fb1eea7e95cafc281141ead9ef77796e43711b17edccaab67c5e791a.yml
33
openapi_spec_hash: 12501774d0127be4ec1812d613a58e97
4-
config_hash: 830747463ff4d018b5633ce511e88558
4+
config_hash: 5b61cc8c6c31c071a08578ad825b421d

bin/publish-npm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ else
5858
fi
5959

6060
# Publish with the appropriate tag
61-
yarn publish --access public --tag "$TAG"
61+
yarn publish --tag "$TAG"

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"**/*"
1414
],
1515
"private": false,
16+
"publishConfig": {
17+
"access": "public"
18+
},
1619
"scripts": {
1720
"test": "./scripts/test",
1821
"build": "./scripts/build",
@@ -41,15 +44,12 @@
4144
"publint": "^0.2.12",
4245
"ts-jest": "^29.1.0",
4346
"ts-node": "^10.5.0",
44-
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz",
47+
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.9/tsc-multi.tgz",
4548
"tsconfig-paths": "^4.0.0",
49+
"tslib": "^2.8.1",
4650
"typescript": "5.8.3",
4751
"typescript-eslint": "8.31.1"
4852
},
49-
"imports": {
50-
"hanzoai": ".",
51-
"hanzoai/*": "./src/*"
52-
},
5353
"exports": {
5454
".": {
5555
"import": "./dist/index.mjs",

packages/mcp-server/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,43 @@ over time, you can manually enable or disable certain capabilities:
128128
--resource=cards,accounts --operation=read --tag=kyc --no-tool=create_cards
129129
```
130130

131+
## Running remotely
132+
133+
Launching the client with `--transport=http` launches the server as a remote server using Streamable HTTP transport. The `--port` setting can choose the port it will run on, and the `--socket` setting allows it to run on a Unix socket.
134+
135+
Authorization can be provided via the following headers:
136+
| Header | Equivalent client option | Security scheme |
137+
| --------------------------- | ------------------------ | --------------- |
138+
| `Ocp-Apim-Subscription-Key` | `apiKey` | APIKeyHeader |
139+
140+
A configuration JSON for this server might look like this, assuming the server is hosted at `http://localhost:3000`:
141+
142+
```json
143+
{
144+
"mcpServers": {
145+
"hanzoai_api": {
146+
"url": "http://localhost:3000",
147+
"headers": {
148+
"Ocp-Apim-Subscription-Key": "My API Key"
149+
}
150+
}
151+
}
152+
}
153+
```
154+
155+
The command-line arguments for filtering tools and specifying clients can also be used as query parameters in the URL.
156+
For example, to exclude specific tools while including others, use the URL:
157+
158+
```
159+
http://localhost:3000?resource=cards&resource=accounts&no_tool=create_cards
160+
```
161+
162+
Or, to configure for the Cursor client, with a custom max tool name length, use the URL:
163+
164+
```
165+
http://localhost:3000?client=cursor&capability=tool-name-length%3D40
166+
```
167+
131168
## Importing the tools and server individually
132169

133170
```js

packages/mcp-server/build

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,27 @@ cp tsconfig.dist-src.json dist/src/tsconfig.json
3030
chmod +x dist/index.js
3131

3232
DIST_PATH=./dist PKG_IMPORT_PATH=hanzoai-mcp/ node ../../scripts/utils/postprocess-files.cjs
33+
34+
# mcp bundle
35+
rm -rf dist-bundle hanzoai_api.dxt; mkdir dist-bundle
36+
37+
# copy package.json
38+
PKG_JSON_PATH=../../packages/mcp-server/package.json node ../../scripts/utils/make-dist-package-json.cjs > dist-bundle/package.json
39+
40+
# copy files
41+
node scripts/copy-bundle-files.cjs
42+
43+
# install runtime deps
44+
cd dist-bundle
45+
npm install
46+
cd ..
47+
48+
# pack bundle
49+
cp manifest.json dist-bundle
50+
51+
npx dxt pack dist-bundle hanzoai_api.dxt
52+
53+
npx dxt sign hanzoai_api.dxt --self-signed
54+
55+
# clean up
56+
rm -rf dist-bundle

packages/mcp-server/manifest.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"dxt_version": "0.1",
3+
"name": "hanzoai-mcp",
4+
"version": "0.1.0-alpha.1",
5+
"description": "The official MCP Server for the Hanzo API",
6+
"author": {
7+
"name": "Hanzo",
8+
"email": "[email protected]"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/hanzoai/js-sdk.git"
13+
},
14+
"homepage": "https://github.com/hanzoai/js-sdk/tree/main/packages/mcp-server#readme",
15+
"documentation": "https://docs.hanzo.ai",
16+
"server": {
17+
"type": "node",
18+
"entry_point": "${__dirname}/index.js",
19+
"mcp_config": {
20+
"command": "node",
21+
"args": ["${__dirname}/index.js"],
22+
"env": {
23+
"HANZO_API_KEY": "${user_config.HANZO_API_KEY}"
24+
}
25+
}
26+
},
27+
"user_config": {
28+
"HANZO_API_KEY": {
29+
"title": "api_key",
30+
"description": "The default name of the subscription key header of Azure",
31+
"required": true,
32+
"type": "string"
33+
}
34+
},
35+
"tools_generated": true,
36+
"compatibility": {
37+
"runtimes": {
38+
"node": ">=18.0.0"
39+
}
40+
},
41+
"keywords": ["api"]
42+
}

packages/mcp-server/package.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"license": "Apache-2.0",
1616
"packageManager": "[email protected]",
1717
"private": false,
18+
"publishConfig": {
19+
"access": "public"
20+
},
1821
"scripts": {
1922
"test": "jest",
2023
"build": "bash ./build",
@@ -28,18 +31,28 @@
2831
},
2932
"dependencies": {
3033
"hanzoai": "file:../../dist/",
34+
"@cloudflare/cabidela": "^0.2.4",
3135
"@modelcontextprotocol/sdk": "^1.11.5",
32-
"jq-web": "https://github.com/stainless-api/jq-web/releases/download/v0.8.2/jq-web.tar.gz",
36+
"@valtown/deno-http-worker": "^0.0.21",
37+
"cors": "^2.8.5",
38+
"express": "^5.1.0",
39+
"jq-web": "https://github.com/stainless-api/jq-web/releases/download/v0.8.6/jq-web.tar.gz",
40+
"qs": "^6.14.0",
3341
"yargs": "^17.7.2",
34-
"@cloudflare/cabidela": "^0.2.4",
3542
"zod": "^3.25.20",
36-
"zod-to-json-schema": "^3.24.5"
43+
"zod-to-json-schema": "^3.24.5",
44+
"zod-validation-error": "^4.0.1"
3745
},
3846
"bin": {
3947
"mcp-server": "dist/index.js"
4048
},
4149
"devDependencies": {
50+
"@anthropic-ai/dxt": "^0.2.6",
51+
"@types/cors": "^2.8.19",
52+
"@types/express": "^5.0.3",
4253
"@types/jest": "^29.4.0",
54+
"@types/qs": "^6.14.0",
55+
"@types/yargs": "^17.0.8",
4356
"@typescript-eslint/eslint-plugin": "8.31.1",
4457
"@typescript-eslint/parser": "8.31.1",
4558
"eslint": "^8.49.0",
@@ -50,7 +63,7 @@
5063
"ts-jest": "^29.1.0",
5164
"ts-morph": "^19.0.0",
5265
"ts-node": "^10.5.0",
53-
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz",
66+
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.9/tsc-multi.tgz",
5467
"tsconfig-paths": "^4.0.0",
5568
"typescript": "5.8.3"
5669
},
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const pkgJson = require('../dist-bundle/package.json');
4+
5+
const distDir = path.resolve(__dirname, '..', 'dist');
6+
const distBundleDir = path.resolve(__dirname, '..', 'dist-bundle');
7+
const distBundlePkgJson = path.join(distBundleDir, 'package.json');
8+
9+
async function* walk(dir) {
10+
for await (const d of await fs.promises.opendir(dir)) {
11+
const entry = path.join(dir, d.name);
12+
if (d.isDirectory()) yield* walk(entry);
13+
else if (d.isFile()) yield entry;
14+
}
15+
}
16+
17+
async function copyFiles() {
18+
// copy runtime files
19+
for await (const file of walk(distDir)) {
20+
if (!/[cm]?js$/.test(file)) continue;
21+
const dest = path.join(distBundleDir, path.relative(distDir, file));
22+
await fs.promises.mkdir(path.dirname(dest), { recursive: true });
23+
await fs.promises.copyFile(file, dest);
24+
}
25+
26+
// replace package.json reference with local reference
27+
for (const dep in pkgJson.dependencies) {
28+
if (dep === 'hanzoai') {
29+
pkgJson.dependencies[dep] = 'file:../../../dist/';
30+
}
31+
}
32+
33+
await fs.promises.writeFile(distBundlePkgJson, JSON.stringify(pkgJson, null, 2));
34+
}
35+
36+
copyFiles();

0 commit comments

Comments
 (0)