Skip to content

Commit dcfff9e

Browse files
feat(api): pre-launch SDK release
1 parent 1fee692 commit dcfff9e

File tree

98 files changed

+6660
-27278
lines changed

Some content is hidden

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

98 files changed

+6660
-27278
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
URL: https://pkg.stainless.com/s?subpackage=mcp-server
7676
AUTH: ${{ steps.github-oidc.outputs.github_token }}
7777
SHA: ${{ github.sha }}
78-
BUILD_PATH: packages/mcp-server/dist
78+
BASE_PATH: packages/mcp-server
7979
run: ./scripts/utils/upload-artifact.sh
8080
test:
8181
timeout-minutes: 10

.github/workflows/publish-npm.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
publish:
1717
name: publish
1818
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
1921

2022
steps:
2123
- uses: actions/checkout@v4
@@ -39,3 +41,10 @@ jobs:
3941
yarn tsn scripts/publish-packages.ts "{ \"paths_released\": \"$PATHS_RELEASED\" }"
4042
env:
4143
NPM_TOKEN: ${{ secrets.FLOWGLAD_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/flowglad_node_api.mcpb
49+
env:
50+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ dist
77
dist-deno
88
/*.tgz
99
.idea/
10-
10+
.eslintcache
11+
dist-bundle
12+
*.mcpb

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 46
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/flowglad%2Fflowglad-0cf7bce0c17d6f5a651950ab9f46224548af6b420a8a18883ae357c834ab6148.yml
3-
openapi_spec_hash: 4d78e958c164eaa79116965799ff10c7
4-
config_hash: 5cd4df36fa4da9901706710955ea260e
1+
configured_endpoints: 45
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/flowglad%2Fflowglad-a1eeb4fac4d6f2e5a1bed0a6ef5abfc4172e8d989c24343860b8a07a389ea65b.yml
3+
openapi_spec_hash: 1bd6007e37eeb62e1dc85da4f939ed1d
4+
config_hash: b3cf56eeb5f18b49019b9be6e30263c0

api.md

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
1+
# Shared
2+
3+
Types:
4+
5+
- <code><a href="./src/resources/shared.ts">BillingAddress</a></code>
6+
- <code><a href="./src/resources/shared.ts">NonRenewingSubscriptionRecord</a></code>
7+
- <code><a href="./src/resources/shared.ts">PaymentMethodClientSelectSchema</a></code>
8+
- <code><a href="./src/resources/shared.ts">PricingModelDetailsRecord</a></code>
9+
- <code><a href="./src/resources/shared.ts">PurchaseInvoiceClientSelectSchema</a></code>
10+
- <code><a href="./src/resources/shared.ts">StandaloneInvoiceClientSelectSchema</a></code>
11+
- <code><a href="./src/resources/shared.ts">StandardSubscriptionRecord</a></code>
12+
- <code><a href="./src/resources/shared.ts">StaticInvoiceLineItemClientSelectSchema</a></code>
13+
- <code><a href="./src/resources/shared.ts">SubscriptionInvoiceClientSelectSchema</a></code>
14+
- <code><a href="./src/resources/shared.ts">ToggleFeatureClientSelectSchema</a></code>
15+
- <code><a href="./src/resources/shared.ts">UsageCreditGrantFeatureClientSelectSchema</a></code>
16+
- <code><a href="./src/resources/shared.ts">UsageInvoiceLineItemClientSelectSchema</a></code>
17+
- <code><a href="./src/resources/shared.ts">UsageMeterClientSelectSchema</a></code>
18+
119
# Invoices
220

321
Types:
422

5-
- <code><a href="./src/resources/invoices.ts">InvoiceCreateResponse</a></code>
623
- <code><a href="./src/resources/invoices.ts">InvoiceRetrieveResponse</a></code>
724
- <code><a href="./src/resources/invoices.ts">InvoiceListResponse</a></code>
825

926
Methods:
1027

11-
- <code title="post /api/v1/invoices">client.invoices.<a href="./src/resources/invoices.ts">create</a>({ ...params }) -> InvoiceCreateResponse</code>
1228
- <code title="get /api/v1/invoices/{id}">client.invoices.<a href="./src/resources/invoices.ts">retrieve</a>(id) -> InvoiceRetrieveResponse</code>
1329
- <code title="get /api/v1/invoices">client.invoices.<a href="./src/resources/invoices.ts">list</a>({ ...params }) -> InvoiceListResponse</code>
1430

@@ -24,30 +40,36 @@ Methods:
2440
- <code title="get /api/v1/invoice-line-items/{id}">client.invoiceLineItems.<a href="./src/resources/invoice-line-items.ts">retrieve</a>(id) -> InvoiceLineItemRetrieveResponse</code>
2541
- <code title="get /api/v1/invoice-line-items">client.invoiceLineItems.<a href="./src/resources/invoice-line-items.ts">list</a>({ ...params }) -> InvoiceLineItemListResponse</code>
2642

27-
# Catalogs
43+
# PricingModels
2844

2945
Types:
3046

31-
- <code><a href="./src/resources/catalogs.ts">CatalogCreateResponse</a></code>
32-
- <code><a href="./src/resources/catalogs.ts">CatalogRetrieveResponse</a></code>
33-
- <code><a href="./src/resources/catalogs.ts">CatalogUpdateResponse</a></code>
34-
- <code><a href="./src/resources/catalogs.ts">CatalogListResponse</a></code>
35-
- <code><a href="./src/resources/catalogs.ts">CatalogCloneResponse</a></code>
36-
- <code><a href="./src/resources/catalogs.ts">CatalogRetrieveDefaultResponse</a></code>
47+
- <code><a href="./src/resources/pricing-models.ts">PricingModelClientSelectSchema</a></code>
48+
- <code><a href="./src/resources/pricing-models.ts">PricingModelCreateResponse</a></code>
49+
- <code><a href="./src/resources/pricing-models.ts">PricingModelRetrieveResponse</a></code>
50+
- <code><a href="./src/resources/pricing-models.ts">PricingModelUpdateResponse</a></code>
51+
- <code><a href="./src/resources/pricing-models.ts">PricingModelListResponse</a></code>
52+
- <code><a href="./src/resources/pricing-models.ts">PricingModelCloneResponse</a></code>
53+
- <code><a href="./src/resources/pricing-models.ts">PricingModelRetrieveDefaultResponse</a></code>
3754

3855
Methods:
3956

40-
- <code title="post /api/v1/catalogs">client.catalogs.<a href="./src/resources/catalogs.ts">create</a>({ ...params }) -> CatalogCreateResponse</code>
41-
- <code title="get /api/v1/catalogs/{id}">client.catalogs.<a href="./src/resources/catalogs.ts">retrieve</a>(id) -> CatalogRetrieveResponse</code>
42-
- <code title="put /api/v1/catalogs/{id}">client.catalogs.<a href="./src/resources/catalogs.ts">update</a>(id, { ...params }) -> CatalogUpdateResponse</code>
43-
- <code title="get /api/v1/catalogs">client.catalogs.<a href="./src/resources/catalogs.ts">list</a>({ ...params }) -> CatalogListResponse</code>
44-
- <code title="post /api/v1/catalogs/{id}/clone">client.catalogs.<a href="./src/resources/catalogs.ts">clone</a>(id, { ...params }) -> CatalogCloneResponse</code>
45-
- <code title="get /api/v1/catalogs/default">client.catalogs.<a href="./src/resources/catalogs.ts">retrieveDefault</a>() -> CatalogRetrieveDefaultResponse</code>
57+
- <code title="post /api/v1/pricing-models">client.pricingModels.<a href="./src/resources/pricing-models.ts">create</a>({ ...params }) -> PricingModelCreateResponse</code>
58+
- <code title="get /api/v1/pricing-models/{id}">client.pricingModels.<a href="./src/resources/pricing-models.ts">retrieve</a>(id) -> PricingModelRetrieveResponse</code>
59+
- <code title="put /api/v1/pricing-models/{id}">client.pricingModels.<a href="./src/resources/pricing-models.ts">update</a>(id, { ...params }) -> PricingModelUpdateResponse</code>
60+
- <code title="get /api/v1/pricing-models">client.pricingModels.<a href="./src/resources/pricing-models.ts">list</a>({ ...params }) -> PricingModelListResponse</code>
61+
- <code title="post /api/v1/pricing-models/{id}/clone">client.pricingModels.<a href="./src/resources/pricing-models.ts">clone</a>(id, { ...params }) -> PricingModelCloneResponse</code>
62+
- <code title="get /api/v1/pricing-models/default">client.pricingModels.<a href="./src/resources/pricing-models.ts">retrieveDefault</a>() -> PricingModelRetrieveDefaultResponse</code>
4663

4764
# CheckoutSessions
4865

4966
Types:
5067

68+
- <code><a href="./src/resources/checkout-sessions.ts">ActivateSubscriptionCheckoutSessionClientSelectSchema</a></code>
69+
- <code><a href="./src/resources/checkout-sessions.ts">AddPaymentMethodCheckoutSessionClientSelectSchema</a></code>
70+
- <code><a href="./src/resources/checkout-sessions.ts">InvoiceCheckoutSessionClientSelectSchema</a></code>
71+
- <code><a href="./src/resources/checkout-sessions.ts">ProductCheckoutSessionClientSelectSchema</a></code>
72+
- <code><a href="./src/resources/checkout-sessions.ts">PurchaseCheckoutSessionClientSelectSchema</a></code>
5173
- <code><a href="./src/resources/checkout-sessions.ts">CheckoutSessionCreateResponse</a></code>
5274
- <code><a href="./src/resources/checkout-sessions.ts">CheckoutSessionRetrieveResponse</a></code>
5375
- <code><a href="./src/resources/checkout-sessions.ts">CheckoutSessionListResponse</a></code>
@@ -62,6 +84,7 @@ Methods:
6284

6385
Types:
6486

87+
- <code><a href="./src/resources/products.ts">ProductClientSelectSchema</a></code>
6588
- <code><a href="./src/resources/products.ts">ProductCreateResponse</a></code>
6689
- <code><a href="./src/resources/products.ts">ProductRetrieveResponse</a></code>
6790
- <code><a href="./src/resources/products.ts">ProductUpdateResponse</a></code>
@@ -78,6 +101,9 @@ Methods:
78101

79102
Types:
80103

104+
- <code><a href="./src/resources/prices.ts">SinglePaymentPriceClientSelectSchema</a></code>
105+
- <code><a href="./src/resources/prices.ts">SubscriptionPriceClientSelectSchema</a></code>
106+
- <code><a href="./src/resources/prices.ts">UsagePriceClientSelectSchema</a></code>
81107
- <code><a href="./src/resources/prices.ts">PriceCreateResponse</a></code>
82108
- <code><a href="./src/resources/prices.ts">PriceUpdateResponse</a></code>
83109
- <code><a href="./src/resources/prices.ts">PriceListResponse</a></code>
@@ -92,6 +118,9 @@ Methods:
92118

93119
Types:
94120

121+
- <code><a href="./src/resources/discounts.ts">DefaultDiscountClientSelectSchema</a></code>
122+
- <code><a href="./src/resources/discounts.ts">ForeverDiscountClientSelectSchema</a></code>
123+
- <code><a href="./src/resources/discounts.ts">NumberOfPaymentsDiscountClientSelectSchema</a></code>
95124
- <code><a href="./src/resources/discounts.ts">DiscountCreateResponse</a></code>
96125
- <code><a href="./src/resources/discounts.ts">DiscountRetrieveResponse</a></code>
97126
- <code><a href="./src/resources/discounts.ts">DiscountUpdateResponse</a></code>
@@ -108,6 +137,9 @@ Methods:
108137

109138
Types:
110139

140+
- <code><a href="./src/resources/customers.ts">CustomerClientSelectSchema</a></code>
141+
- <code><a href="./src/resources/customers.ts">ToggleSubscriptionItemFeatureRecord</a></code>
142+
- <code><a href="./src/resources/customers.ts">UsageCreditGrantSubscriptionItemFeatureClientSelectSchema</a></code>
111143
- <code><a href="./src/resources/customers.ts">CustomerCreateResponse</a></code>
112144
- <code><a href="./src/resources/customers.ts">CustomerRetrieveResponse</a></code>
113145
- <code><a href="./src/resources/customers.ts">CustomerUpdateResponse</a></code>
@@ -126,6 +158,7 @@ Methods:
126158

127159
Types:
128160

161+
- <code><a href="./src/resources/payments.ts">PaymentClientSelectSchema</a></code>
129162
- <code><a href="./src/resources/payments.ts">PaymentRetrieveResponse</a></code>
130163
- <code><a href="./src/resources/payments.ts">PaymentListResponse</a></code>
131164
- <code><a href="./src/resources/payments.ts">PaymentRefundResponse</a></code>

packages/mcp-server/README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ http://localhost:3000?client=cursor&capability=tool-name-length%3D40
170170
import { server, endpoints, init } from "@flowglad/node-mcp/server";
171171

172172
// import a specific tool
173-
import createInvoices from "@flowglad/node-mcp/tools/invoices/create-invoices";
173+
import retrieveInvoices from "@flowglad/node-mcp/tools/invoices/retrieve-invoices";
174174

175175
// initialize the server and all endpoints
176176
init({ server, endpoints });
@@ -195,7 +195,7 @@ const myCustomEndpoint = {
195195
};
196196

197197
// initialize the server with your custom endpoints
198-
init({ server: myServer, endpoints: [createInvoices, myCustomEndpoint] });
198+
init({ server: myServer, endpoints: [retrieveInvoices, myCustomEndpoint] });
199199
```
200200

201201
## Available Tools
@@ -204,7 +204,6 @@ The following tools are available in this MCP server.
204204

205205
### Resource `invoices`:
206206

207-
- `create_invoices` (`write`): Create Invoice
208207
- `retrieve_invoices` (`read`): Get Invoice
209208
- `list_invoices` (`read`): List Invoices
210209

@@ -213,14 +212,14 @@ The following tools are available in this MCP server.
213212
- `retrieve_invoice_line_items` (`read`): Get Invoice Line Item
214213
- `list_invoice_line_items` (`read`): List Invoice Line Items
215214

216-
### Resource `catalogs`:
215+
### Resource `pricing_models`:
217216

218-
- `create_catalogs` (`write`): Create Catalog
219-
- `retrieve_catalogs` (`read`): Get Catalog
220-
- `update_catalogs` (`write`): Update Catalog
221-
- `list_catalogs` (`read`): List Catalogs
222-
- `clone_catalogs` (`write`): Clone a Catalog
223-
- `retrieve_default_catalogs` (`read`): Get Default Catalog for Organization
217+
- `create_pricing_models` (`write`): Create Pricing Model
218+
- `retrieve_pricing_models` (`read`): Get Pricing Model
219+
- `update_pricing_models` (`write`): Update Pricing Model
220+
- `list_pricing_models` (`read`): List Pricing Models
221+
- `clone_pricing_models` (`write`): Clone a PricingModel
222+
- `retrieve_default_pricing_models` (`read`): Get Default Pricing Model for Organization
224223

225224
### Resource `checkout_sessions`:
226225

@@ -272,7 +271,7 @@ The following tools are available in this MCP server.
272271
- `create_subscriptions` (`write`): Create Subscription
273272
- `retrieve_subscriptions` (`read`): Get Subscription
274273
- `list_subscriptions` (`read`): List Subscriptions
275-
- `adjust_subscriptions` (`write`): Adjust a Subscription
274+
- `adjust_subscriptions` (`write`): Note: Immediate adjustments are in private preview (Please let us know you use this feature: https://github.com/flowglad/flowglad/issues/616). Adjustments at the end of the current billing period are generally available.
276275
- `cancel_subscriptions` (`write`): Cancel a Subscription
277276

278277
### Resource `usage_events`:

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=@flowglad/node-mcp/ node ../../scripts/utils/postprocess-files.cjs
33+
34+
# mcp bundle
35+
rm -rf dist-bundle flowglad_node_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 flowglad_node_api.mcpb
52+
53+
npx mcpb sign flowglad_node_api.mcpb --self-signed
54+
55+
# clean up
56+
rm -rf dist-bundle

packages/mcp-server/manifest.json

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

packages/mcp-server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"mcp-server": "dist/index.js"
4848
},
4949
"devDependencies": {
50+
"@anthropic-ai/mcpb": "^1.1.0",
5051
"@types/cors": "^2.8.19",
5152
"@types/express": "^5.0.3",
5253
"@types/jest": "^29.4.0",
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 === '@flowglad/node') {
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)