Skip to content

Commit 19ac828

Browse files
chore: configure new SDK language
1 parent abf7b0b commit 19ac828

35 files changed

+5321
-9
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 3 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/lithic-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
@@ -79,11 +88,14 @@ 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
89101
examples:

.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.LITHIC_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/lithic_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: 176
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-4ecc06edca2cfad4eaf11573611e89823fda5f56370bac5cd02a498a6b277d09.yml
33
openapi_spec_hash: 8f4a30bec4348cbde85b1e65bef9189a
4-
config_hash: 9dddee5f7af579864599849cb28a0770
4+
config_hash: 751a4cc75aa0276b40cc2c7879b24dea

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ This library provides convenient access to the Lithic REST API from server-side
66

77
The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). The full API of this library can be found in [api.md](api.md).
88

9+
## MCP Server
10+
11+
Use the Lithic MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.
12+
13+
[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=lithic-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImxpdGhpYy1tY3AiXX0)
14+
[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22lithic-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22lithic-mcp%22%5D%7D)
15+
16+
> Note: You may need to set environment variables in your MCP client.
17+
918
## Installation
1019

1120
```sh

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default tseslint.config(
3434
},
3535
},
3636
{
37-
files: ['tests/**', 'examples/**'],
37+
files: ['tests/**', 'examples/**', 'packages/**'],
3838
rules: {
3939
'no-restricted-imports': 'off',
4040
},

packages/mcp-server/README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Lithic TypeScript MCP Server
2+
3+
## Installation
4+
5+
### Direct invocation
6+
7+
You can run the MCP Server directly via `npx`:
8+
9+
```sh
10+
export LITHIC_API_KEY="My Lithic API Key"
11+
export LITHIC_WEBHOOK_SECRET="My Webhook Secret"
12+
export LITHIC_ENVIRONMENT="production"
13+
npx -y lithic-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+
"lithic_api": {
27+
"command": "npx",
28+
"args": ["-y", "lithic-mcp"],
29+
"env": {
30+
"LITHIC_API_KEY": "My Lithic API Key",
31+
"LITHIC_WEBHOOK_SECRET": "My Webhook Secret",
32+
"LITHIC_ENVIRONMENT": "production"
33+
}
34+
}
35+
}
36+
}
37+
```
38+
39+
### Cursor
40+
41+
If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables
42+
in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server.
43+
44+
[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=lithic-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImxpdGhpYy1tY3AiXSwiZW52Ijp7IkxJVEhJQ19BUElfS0VZIjoiU2V0IHlvdXIgTElUSElDX0FQSV9LRVkgaGVyZS4iLCJMSVRISUNfV0VCSE9PS19TRUNSRVQiOiJTZXQgeW91ciBMSVRISUNfV0VCSE9PS19TRUNSRVQgaGVyZS4ifX0)
45+
46+
### VS Code
47+
48+
If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables
49+
in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration.
50+
51+
[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22lithic-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22lithic-mcp%22%5D%2C%22env%22%3A%7B%22LITHIC_API_KEY%22%3A%22Set%20your%20LITHIC_API_KEY%20here.%22%2C%22LITHIC_WEBHOOK_SECRET%22%3A%22Set%20your%20LITHIC_WEBHOOK_SECRET%20here.%22%7D%7D)
52+
53+
### Claude Code
54+
55+
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
56+
environment variables in Claude Code's `.claude.json`, which can be found in your home directory.
57+
58+
```
59+
claude mcp add lithic_mcp_api --env LITHIC_API_KEY="Your LITHIC_API_KEY here." LITHIC_WEBHOOK_SECRET="Your LITHIC_WEBHOOK_SECRET here." -- npx -y lithic-mcp
60+
```
61+
62+
## Code Mode
63+
64+
This MCP server is built on the "Code Mode" tool scheme. In this MCP Server,
65+
your agent will write code against the TypeScript SDK, which will then be executed in an
66+
isolated sandbox. To accomplish this, the server will expose two tools to your agent:
67+
68+
- The first tool is a docs search tool, which can be used to generically query for
69+
documentation about your API/SDK.
70+
71+
- The second tool is a code tool, where the agent can write code against the TypeScript SDK.
72+
The code will be executed in a sandbox environment without web or filesystem access. Then,
73+
anything the code returns or prints will be returned to the agent as the result of the
74+
tool call.
75+
76+
Using this scheme, agents are capable of performing very complex tasks deterministically
77+
and repeatably.
78+
79+
## Running remotely
80+
81+
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.
82+
83+
Authorization can be provided via the following headers:
84+
| Header | Equivalent client option | Security scheme |
85+
| ------------------ | ------------------------ | --------------- |
86+
| `x-lithic-api-key` | `apiKey` | ApiKeyAuth |
87+
88+
A configuration JSON for this server might look like this, assuming the server is hosted at `http://localhost:3000`:
89+
90+
```json
91+
{
92+
"mcpServers": {
93+
"lithic_api": {
94+
"url": "http://localhost:3000",
95+
"headers": {
96+
"x-lithic-api-key": "My Lithic API Key"
97+
}
98+
}
99+
}
100+
}
101+
```

packages/mcp-server/build

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
set -exuo pipefail
3+
4+
rm -rf dist; mkdir dist
5+
6+
# Copy src to dist/src and build from dist/src into dist, so that
7+
# the source map for index.js.map will refer to ./src/index.ts etc
8+
cp -rp src README.md dist
9+
10+
for file in LICENSE; do
11+
if [ -e "../../${file}" ]; then cp "../../${file}" dist; fi
12+
done
13+
14+
for file in CHANGELOG.md; do
15+
if [ -e "${file}" ]; then cp "${file}" dist; fi
16+
done
17+
18+
# this converts the export map paths for the dist directory
19+
# and does a few other minor things
20+
PKG_JSON_PATH=../../packages/mcp-server/package.json node ../../scripts/utils/make-dist-package-json.cjs > dist/package.json
21+
22+
# updates the `lithic` dependency to point to NPM
23+
node scripts/postprocess-dist-package-json.cjs
24+
25+
# build to .js/.mjs/.d.ts files
26+
./node_modules/.bin/tsc-multi
27+
28+
cp tsconfig.dist-src.json dist/src/tsconfig.json
29+
30+
chmod +x dist/index.js
31+
32+
DIST_PATH=./dist PKG_IMPORT_PATH=lithic-mcp/ node ../../scripts/utils/postprocess-files.cjs
33+
34+
# mcp bundle
35+
rm -rf dist-bundle lithic_api.mcpb; 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 mcpb pack dist-bundle lithic_api.mcpb
52+
53+
npx mcpb sign lithic_api.mcpb --self-signed
54+
55+
# clean up
56+
rm -rf dist-bundle

packages/mcp-server/jest.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { JestConfigWithTsJest } from 'ts-jest';
2+
3+
const config: JestConfigWithTsJest = {
4+
preset: 'ts-jest/presets/default-esm',
5+
testEnvironment: 'node',
6+
transform: {
7+
'^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }],
8+
},
9+
moduleNameMapper: {
10+
'^lithic-mcp$': '<rootDir>/src/index.ts',
11+
'^lithic-mcp/(.*)$': '<rootDir>/src/$1',
12+
},
13+
modulePathIgnorePatterns: ['<rootDir>/dist/'],
14+
testPathIgnorePatterns: ['scripts'],
15+
};
16+
17+
export default config;

0 commit comments

Comments
 (0)