Skip to content

Commit 93ea751

Browse files
chore: configure new SDK language
1 parent cda7644 commit 93ea751

Some content is hidden

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

71 files changed

+11182
-7
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Set up Node
4747
uses: actions/setup-node@v4
4848
with:
49-
node-version: '18'
49+
node-version: '20'
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/arcade-engine-node'
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
@@ -79,10 +88,13 @@ jobs:
7988
- name: Set up Node
8089
uses: actions/setup-node@v4
8190
with:
82-
node-version: '20'
91+
node-version: '22'
8392

8493
- name: Bootstrap
8594
run: ./scripts/bootstrap
8695

96+
- name: Build
97+
run: ./scripts/build
98+
8799
- name: Run tests
88100
run: ./scripts/test

.github/workflows/publish-npm.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
name: Publish NPM
55
on:
66
workflow_dispatch:
7+
inputs:
8+
path:
9+
description: The path to run the release in, e.g. '.' or 'packages/mcp-server'
10+
required: true
711

812
release:
913
types: [published]
@@ -12,6 +16,8 @@ jobs:
1216
publish:
1317
name: publish
1418
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
1521

1622
steps:
1723
- uses: actions/checkout@v4
@@ -27,6 +33,18 @@ jobs:
2733
2834
- name: Publish to NPM
2935
run: |
30-
bash ./bin/publish-npm
36+
if [ -n "${{ github.event.inputs.path }}" ]; then
37+
PATHS_RELEASED='[\"${{ github.event.inputs.path }}\"]'
38+
else
39+
PATHS_RELEASED='[\".\", \"packages/mcp-server\"]'
40+
fi
41+
yarn tsn scripts/publish-packages.ts "{ \"paths_released\": \"$PATHS_RELEASED\" }"
3142
env:
3243
NPM_TOKEN: ${{ secrets.ARCADE_NPM_TOKEN || secrets.NPM_TOKEN }}
44+
45+
- name: Upload MCP Server DXT GitHub release asset
46+
run: |
47+
gh release upload ${{ github.event.release.tag_name }} \
48+
packages/mcp-server/arcadeai_arcadejs_api.mcpb
49+
env:
50+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ dist-deno
88
/*.tgz
99
.idea/
1010
.eslintcache
11-
11+
dist-bundle
12+
*.mcpb

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ CHANGELOG.md
44
/deno
55

66
# don't format tsc output, will break source maps
7-
/dist
7+
dist

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 30
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/arcade-ai%2Farcade-engine-7ecb40b6650ff002eed02efd1b59c630abe1fb9eb70c9c916c15b115260e5003.yml
33
openapi_spec_hash: 2e5c04d1a50afcd0bdbd9737cec227c9
4-
config_hash: b31a3f1bbe9abcc7bb144942d88ad1b6
4+
config_hash: f26ae67630e2fac8d08a018eefd1d2d9

packages/mcp-server/README.md

Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
# Arcade Node MCP Server
2+
3+
It is generated with [Stainless](https://www.stainless.com/).
4+
5+
## Installation
6+
7+
### Direct invocation
8+
9+
You can run the MCP Server directly via `npx`:
10+
11+
```sh
12+
export ARCADE_API_KEY="My API Key"
13+
npx -y @arcadeai/arcadejs-mcp@latest
14+
```
15+
16+
### Via MCP Client
17+
18+
There is a partial list of existing clients at [modelcontextprotocol.io](https://modelcontextprotocol.io/clients). If you already
19+
have a client, consult their documentation to install the MCP server.
20+
21+
For clients with a configuration JSON, it might look something like this:
22+
23+
```json
24+
{
25+
"mcpServers": {
26+
"arcadeai_arcadejs_api": {
27+
"command": "npx",
28+
"args": ["-y", "@arcadeai/arcadejs-mcp", "--client=claude", "--tools=dynamic"],
29+
"env": {
30+
"ARCADE_API_KEY": "My API Key"
31+
}
32+
}
33+
}
34+
}
35+
```
36+
37+
### Cursor
38+
39+
If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables
40+
in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server.
41+
42+
[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=@arcadeai/arcadejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBhcmNhZGVhaS9hcmNhZGVqcy1tY3AiXSwiZW52Ijp7IkFSQ0FERV9BUElfS0VZIjoiU2V0IHlvdXIgQVJDQURFX0FQSV9LRVkgaGVyZS4ifX0)
43+
44+
### VS Code
45+
46+
If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables
47+
in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration.
48+
49+
[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40arcadeai%2Farcadejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40arcadeai%2Farcadejs-mcp%22%5D%2C%22env%22%3A%7B%22ARCADE_API_KEY%22%3A%22Set%20your%20ARCADE_API_KEY%20here.%22%7D%7D)
50+
51+
### Claude Code
52+
53+
If you use Claude Code, you can install the MCP server by running the command below in your terminal. You will need to set your
54+
environment variables in Claude Code's `.claude.json`, which can be found in your home directory.
55+
56+
```
57+
claude mcp add --transport stdio arcadeai_arcadejs_api --env ARCADE_API_KEY="Your ARCADE_API_KEY here." -- npx -y @arcadeai/arcadejs-mcp
58+
```
59+
60+
## Exposing endpoints to your MCP Client
61+
62+
There are three ways to expose endpoints as tools in the MCP server:
63+
64+
1. Exposing one tool per endpoint, and filtering as necessary
65+
2. Exposing a set of tools to dynamically discover and invoke endpoints from the API
66+
3. Exposing a docs search tool and a code execution tool, allowing the client to write code to be executed against the TypeScript client
67+
68+
### Filtering endpoints and tools
69+
70+
You can run the package on the command line to discover and filter the set of tools that are exposed by the
71+
MCP Server. This can be helpful for large APIs where including all endpoints at once is too much for your AI's
72+
context window.
73+
74+
You can filter by multiple aspects:
75+
76+
- `--tool` includes a specific tool by name
77+
- `--resource` includes all tools under a specific resource, and can have wildcards, e.g. `my.resource*`
78+
- `--operation` includes just read (get/list) or just write operations
79+
80+
### Dynamic tools
81+
82+
If you specify `--tools=dynamic` to the MCP server, instead of exposing one tool per endpoint in the API, it will
83+
expose the following tools:
84+
85+
1. `list_api_endpoints` - Discovers available endpoints, with optional filtering by search query
86+
2. `get_api_endpoint_schema` - Gets detailed schema information for a specific endpoint
87+
3. `invoke_api_endpoint` - Executes any endpoint with the appropriate parameters
88+
89+
This allows you to have the full set of API endpoints available to your MCP Client, while not requiring that all
90+
of their schemas be loaded into context at once. Instead, the LLM will automatically use these tools together to
91+
search for, look up, and invoke endpoints dynamically. However, due to the indirect nature of the schemas, it
92+
can struggle to provide the correct properties a bit more than when tools are imported explicitly. Therefore,
93+
you can opt-in to explicit tools, the dynamic tools, or both.
94+
95+
See more information with `--help`.
96+
97+
All of these command-line options can be repeated, combined together, and have corresponding exclusion versions (e.g. `--no-tool`).
98+
99+
Use `--list` to see the list of available tools, or see below.
100+
101+
### Code execution
102+
103+
If you specify `--tools=code` to the MCP server, it will expose just two tools:
104+
105+
- `search_docs` - Searches the API documentation and returns a list of markdown results
106+
- `execute` - Runs code against the TypeScript client
107+
108+
This allows the LLM to implement more complex logic by chaining together many API calls without loading
109+
intermediary results into its context window.
110+
111+
The code execution itself happens in a Deno sandbox that has network access only to the base URL for the API.
112+
113+
### Specifying the MCP Client
114+
115+
Different clients have varying abilities to handle arbitrary tools and schemas.
116+
117+
You can specify the client you are using with the `--client` argument, and the MCP server will automatically
118+
serve tools and schemas that are more compatible with that client.
119+
120+
- `--client=<type>`: Set all capabilities based on a known MCP client
121+
122+
- Valid values: `openai-agents`, `claude`, `claude-code`, `cursor`
123+
- Example: `--client=cursor`
124+
125+
Additionally, if you have a client not on the above list, or the client has gotten better
126+
over time, you can manually enable or disable certain capabilities:
127+
128+
- `--capability=<name>`: Specify individual client capabilities
129+
- Available capabilities:
130+
- `top-level-unions`: Enable support for top-level unions in tool schemas
131+
- `valid-json`: Enable JSON string parsing for arguments
132+
- `refs`: Enable support for $ref pointers in schemas
133+
- `unions`: Enable support for union types (anyOf) in schemas
134+
- `formats`: Enable support for format validations in schemas (e.g. date-time, email)
135+
- `tool-name-length=N`: Set maximum tool name length to N characters
136+
- Example: `--capability=top-level-unions --capability=tool-name-length=40`
137+
- Example: `--capability=top-level-unions,tool-name-length=40`
138+
139+
### Examples
140+
141+
1. Filter for read operations on cards:
142+
143+
```bash
144+
--resource=cards --operation=read
145+
```
146+
147+
2. Exclude specific tools while including others:
148+
149+
```bash
150+
--resource=cards --no-tool=create_cards
151+
```
152+
153+
3. Configure for Cursor client with custom max tool name length:
154+
155+
```bash
156+
--client=cursor --capability=tool-name-length=40
157+
```
158+
159+
4. Complex filtering with multiple criteria:
160+
161+
```bash
162+
--resource=cards,accounts --operation=read --tag=kyc --no-tool=create_cards
163+
```
164+
165+
## Running remotely
166+
167+
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.
168+
169+
Authorization can be provided via the following headers:
170+
| Header | Equivalent client option | Security scheme |
171+
| ------------------ | ------------------------ | --------------- |
172+
| `x-arcade-api-key` | `apiKey` | Bearer |
173+
174+
A configuration JSON for this server might look like this, assuming the server is hosted at `http://localhost:3000`:
175+
176+
```json
177+
{
178+
"mcpServers": {
179+
"arcadeai_arcadejs_api": {
180+
"url": "http://localhost:3000",
181+
"headers": {
182+
"x-arcade-api-key": "My API Key"
183+
}
184+
}
185+
}
186+
}
187+
```
188+
189+
The command-line arguments for filtering tools and specifying clients can also be used as query parameters in the URL.
190+
For example, to exclude specific tools while including others, use the URL:
191+
192+
```
193+
http://localhost:3000?resource=cards&resource=accounts&no_tool=create_cards
194+
```
195+
196+
Or, to configure for the Cursor client, with a custom max tool name length, use the URL:
197+
198+
```
199+
http://localhost:3000?client=cursor&capability=tool-name-length%3D40
200+
```
201+
202+
## Importing the tools and server individually
203+
204+
```js
205+
// Import the server, generated endpoints, or the init function
206+
import { server, endpoints, init } from "@arcadeai/arcadejs-mcp/server";
207+
208+
// import a specific tool
209+
import listAdminUserConnections from "@arcadeai/arcadejs-mcp/tools/admin/user-connections/list-admin-user-connections";
210+
211+
// initialize the server and all endpoints
212+
init({ server, endpoints });
213+
214+
// manually start server
215+
const transport = new StdioServerTransport();
216+
await server.connect(transport);
217+
218+
// or initialize your own server with specific tools
219+
const myServer = new McpServer(...);
220+
221+
// define your own endpoint
222+
const myCustomEndpoint = {
223+
tool: {
224+
name: 'my_custom_tool',
225+
description: 'My custom tool',
226+
inputSchema: zodToJsonSchema(z.object({ a_property: z.string() })),
227+
},
228+
handler: async (client: client, args: any) => {
229+
return { myResponse: 'Hello world!' };
230+
})
231+
};
232+
233+
// initialize the server with your custom endpoints
234+
init({ server: myServer, endpoints: [listAdminUserConnections, myCustomEndpoint] });
235+
```
236+
237+
## Available Tools
238+
239+
The following tools are available in this MCP server.
240+
241+
### Resource `admin.user_connections`:
242+
243+
- `list_admin_user_connections` (`read`): List all auth connections
244+
- `delete_admin_user_connections` (`write`): Delete a user/auth provider connection
245+
246+
### Resource `admin.auth_providers`:
247+
248+
- `create_admin_auth_providers` (`write`): Create a new auth provider
249+
- `list_admin_auth_providers` (`read`): List a page of auth providers that are available to the caller
250+
- `delete_admin_auth_providers` (`write`): Delete a specific auth provider
251+
- `get_admin_auth_providers` (`read`): Get the details of a specific auth provider
252+
- `patch_admin_auth_providers` (`write`): Patch an existing auth provider
253+
254+
### Resource `admin.secrets`:
255+
256+
- `create_admin_secrets` (`write`): Create or update a secret
257+
- `list_admin_secrets` (`read`): List all secrets that are visible to the caller
258+
- `delete_admin_secrets` (`write`): Delete a secret by its ID
259+
260+
### Resource `auth`:
261+
262+
- `authorize_auth` (`write`): Starts the authorization process for given authorization requirements
263+
- `confirm_user_auth` (`write`): Confirms a user's details during an authorization flow
264+
- `status_auth` (`read`): Checks the status of an ongoing authorization process for a specific tool.
265+
If 'wait' param is present, does not respond until either the auth status becomes completed or the timeout is reached.
266+
267+
### Resource `health`:
268+
269+
- `check_health` (`read`): Check if Arcade Engine is healthy
270+
271+
### Resource `chat.completions`:
272+
273+
- `create_chat_completions` (`write`): Interact with language models via OpenAI's chat completions API
274+
275+
### Resource `tools`:
276+
277+
- `list_tools` (`read`): Returns a page of tools from the engine configuration, optionally filtered by toolkit
278+
- `authorize_tools` (`write`): Authorizes a user for a specific tool by name
279+
- `execute_tools` (`write`): Executes a tool by name and arguments
280+
- `get_tools` (`read`): Returns the arcade tool specification for a specific tool
281+
282+
### Resource `tools.scheduled`:
283+
284+
- `list_tools_scheduled` (`read`): Returns a page of scheduled tool executions
285+
- `get_tools_scheduled` (`read`): Returns the details for a specific scheduled tool execution
286+
287+
### Resource `tools.formatted`:
288+
289+
- `list_tools_formatted` (`read`): Returns a page of tools from the engine configuration, optionally filtered by toolkit, formatted for a specific provider
290+
- `get_tools_formatted` (`read`): Returns the formatted tool specification for a specific tool, given a provider
291+
292+
### Resource `workers`:
293+
294+
- `create_workers` (`write`): Create a worker
295+
- `update_workers` (`write`): Update a worker
296+
- `list_workers` (`read`): List all workers with their definitions
297+
- `delete_workers` (`write`): Delete a worker
298+
- `get_workers` (`read`): Get a worker by ID
299+
- `health_workers` (`read`): Get the health of a worker
300+
- `tools_workers` (`read`): Returns a page of tools

0 commit comments

Comments
 (0)