Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to NPM in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/CASParser/cas-parser-node/actions/workflows/publish-npm.yml
name: Publish NPM
on:
workflow_dispatch:
inputs:
path:
description: The path to run the release in, e.g. '.' or 'packages/mcp-server'
required: true

release:
types: [published]

jobs:
publish:
name: publish
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v6

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Set up pnpm
uses: pnpm/action-setup@v4

- name: Install dependencies
run: |
pnpm install

- name: Publish to NPM
run: |
if [ -n "${{ github.event.inputs.path }}" ]; then
PATHS_RELEASED='[\"${{ github.event.inputs.path }}\"]'
else
PATHS_RELEASED='[\".\", \"packages/mcp-server\"]'
fi
pnpm tsn scripts/publish-packages.ts "{ \"paths_released\": \"$PATHS_RELEASED\" }"

- name: Upload MCP Server DXT GitHub release asset
run: |
gh release upload ${{ github.event.release.tag_name }} \
packages/mcp-server/cas_parser_node_api.mcpb
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.6.1"
".": "1.6.2"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 17
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-56b0f699c5437d9e5326626d35dfc972c17d01f12cb416c7f4854c8ea6d0e95e.yml
openapi_spec_hash: 158f405c1880706266d83e6ff16b9d2f
config_hash: 7d8b6bdc6c935a3e6dd7092667c00a5e
config_hash: e78bb30ba7c06b2a6d20092a5872aec2
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 1.6.2 (2026-02-14)

Full Changelog: [v1.6.1...v1.6.2](https://github.com/CASParser/cas-parser-node/compare/v1.6.1...v1.6.2)

### Chores

* update SDK settings ([05b29e9](https://github.com/CASParser/cas-parser-node/commit/05b29e9d60bfd19087cb14cabc32f2c8221e8e8a))
* update SDK settings ([2361eff](https://github.com/CASParser/cas-parser-node/commit/2361eff0fb2b2cad4781d0bcf3cbe04524446732))

## 1.6.1 (2026-02-14)

Full Changelog: [v1.6.0...v1.6.1](https://github.com/CASParser/cas-parser-node/compare/v1.6.0...v1.6.1)
Expand Down
18 changes: 16 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ $ cd cas-parser-node
# With yarn
$ yarn link
$ cd ../my-package
$ yarn link cas-parser
$ yarn link cas-parser-node

# With pnpm
$ pnpm link --global
$ cd ../my-package
$ pnpm link -—global cas-parser
$ pnpm link -—global cas-parser-node
```

## Running tests
Expand Down Expand Up @@ -91,3 +91,17 @@ To format and fix all lint issues automatically:
```sh
$ pnpm fix
```

## Publishing and releases

Changes made to this repository via the automated release PR pipeline should publish to npm automatically. If
the changes aren't made through the automated pipeline, you may want to make releases manually.

### Publish with a GitHub workflow

You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/CASParser/cas-parser-node/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up.

### Publish manually

If you need to manually release a package, you can run the `bin/publish-npm` script with an `NPM_TOKEN` set on
the environment.
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cas Parser TypeScript API Library

[![NPM version](<https://img.shields.io/npm/v/cas-parser.svg?label=npm%20(stable)>)](https://npmjs.org/package/cas-parser) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/cas-parser)
[![NPM version](<https://img.shields.io/npm/v/cas-parser-node.svg?label=npm%20(stable)>)](https://npmjs.org/package/cas-parser-node) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/cas-parser-node)

This library provides convenient access to the Cas Parser REST API from server-side TypeScript or JavaScript.

Expand All @@ -20,19 +20,16 @@ Use the Cas Parser MCP Server to enable AI assistants to interact with this API,
## Installation

```sh
npm install git+ssh://git@github.com:CASParser/cas-parser-node.git
npm install cas-parser-node
```

> [!NOTE]
> Once this package is [published to npm](https://www.stainless.com/docs/guides/publish), this will become: `npm install cas-parser`

## Usage

The full API of this library can be found in [api.md](api.md).

<!-- prettier-ignore -->
```js
import CasParser from 'cas-parser';
import CasParser from 'cas-parser-node';

const client = new CasParser({
apiKey: process.env['CAS_PARSER_API_KEY'], // This is the default and can be omitted
Expand All @@ -50,7 +47,7 @@ This library includes TypeScript definitions for all request params and response

<!-- prettier-ignore -->
```ts
import CasParser from 'cas-parser';
import CasParser from 'cas-parser-node';

const client = new CasParser({
apiKey: process.env['CAS_PARSER_API_KEY'], // This is the default and can be omitted
Expand Down Expand Up @@ -173,7 +170,7 @@ The log level can be configured in two ways:
2. Using the `logLevel` client option (overrides the environment variable if set)

```ts
import CasParser from 'cas-parser';
import CasParser from 'cas-parser-node';

const client = new CasParser({
logLevel: 'debug', // Show all log messages
Expand Down Expand Up @@ -201,7 +198,7 @@ When providing a custom logger, the `logLevel` option still controls which messa
below the configured level will not be sent to your logger.

```ts
import CasParser from 'cas-parser';
import CasParser from 'cas-parser-node';
import pino from 'pino';

const logger = pino();
Expand Down Expand Up @@ -270,7 +267,7 @@ globalThis.fetch = fetch;
Or pass it to the client:

```ts
import CasParser from 'cas-parser';
import CasParser from 'cas-parser-node';
import fetch from 'my-fetch';

const client = new CasParser({ fetch });
Expand All @@ -281,7 +278,7 @@ const client = new CasParser({ fetch });
If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)

```ts
import CasParser from 'cas-parser';
import CasParser from 'cas-parser-node';

const client = new CasParser({
fetchOptions: {
Expand All @@ -298,7 +295,7 @@ options to requests:
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg" align="top" width="18" height="21"> **Node** <sup>[[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]</sup>

```ts
import CasParser from 'cas-parser';
import CasParser from 'cas-parser-node';
import * as undici from 'undici';

const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
Expand All @@ -312,7 +309,7 @@ const client = new CasParser({
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg" align="top" width="18" height="21"> **Bun** <sup>[[docs](https://bun.sh/guides/http/proxy)]</sup>

```ts
import CasParser from 'cas-parser';
import CasParser from 'cas-parser-node';

const client = new CasParser({
fetchOptions: {
Expand All @@ -324,7 +321,7 @@ const client = new CasParser({
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg" align="top" width="18" height="21"> **Deno** <sup>[[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]</sup>

```ts
import CasParser from 'npm:cas-parser';
import CasParser from 'npm:cas-parser-node';

const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
const client = new CasParser({
Expand Down
12 changes: 10 additions & 2 deletions bin/publish-npm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

set -eux

npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
if [[ ${NPM_TOKEN:-} ]]; then
npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
elif [[ ! ${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-} ]]; then
echo "ERROR: NPM_TOKEN must be set if not running in a Github Action with id-token permission"
exit 1
fi

pnpm build
cd dist
Expand Down Expand Up @@ -57,5 +62,8 @@ else
TAG="latest"
fi

# Install OIDC compatible npm version
npm install --prefix ../oidc/ npm@11.6.2

# Publish with the appropriate tag
pnpm publish --no-git-checks --tag "$TAG"
pnpm publish --npm-path "$(cd ../ && pwd)/oidc/node_modules/.bin/npm" --no-git-checks --tag "$TAG"
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default tseslint.config(
{
patterns: [
{
regex: '^cas-parser(/.*)?',
regex: '^cas-parser-node(/.*)?',
message: 'Use a relative import, not a package import.',
},
],
Expand Down
4 changes: 2 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const config: JestConfigWithTsJest = {
'^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }],
},
moduleNameMapper: {
'^cas-parser$': '<rootDir>/src/index.ts',
'^cas-parser/(.*)$': '<rootDir>/src/$1',
'^cas-parser-node$': '<rootDir>/src/index.ts',
'^cas-parser-node/(.*)$': '<rootDir>/src/$1',
},
modulePathIgnorePatterns: [
'<rootDir>/ecosystem-tests/',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cas-parser",
"version": "1.6.1",
"name": "cas-parser-node",
"version": "1.6.2",
"description": "The official TypeScript library for the Cas Parser API",
"author": "Cas Parser <sameer@casparser.in>",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/mcp-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ WORKDIR /app
# Copy the build results, preserving directory structure
COPY --from=builder /build .

# Copy the built cas-parser into node_modules
COPY --from=builder /build/dist ./node_modules/cas-parser
# Copy the built cas-parser-node into node_modules
COPY --from=builder /build/dist ./node_modules/cas-parser-node

# Change ownership to nodejs user
RUN chown -R nodejs:nodejs /app
Expand Down
52 changes: 30 additions & 22 deletions packages/mcp-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,18 @@ It is generated with [Stainless](https://www.stainless.com/).

## Installation

### Building
### Direct invocation

Because it's not published yet, clone the repo and build it:
You can run the MCP Server directly via `npx`:

```sh
git clone git@github.com:CASParser/cas-parser-node.git
cd cas-parser-node
./scripts/bootstrap
./scripts/build
```

### Running

```sh
# set env vars as needed
export CAS_PARSER_API_KEY="My API Key"
export CAS_PARSER_ENVIRONMENT="production"
node ./packages/mcp-server/dist/index.js
npx -y cas-parser-mcp@latest
```

> [!NOTE]
> Once this package is [published to npm](https://www.stainless.com/docs/guides/publish), this will become: `npx -y cas-parser-mcp`

### Via MCP Client

[Build the project](#building) as mentioned above.

There is a partial list of existing clients at [modelcontextprotocol.io](https://modelcontextprotocol.io/clients). If you already
have a client, consult their documentation to install the MCP server.

Expand All @@ -39,9 +24,9 @@ For clients with a configuration JSON, it might look something like this:
```json
{
"mcpServers": {
"cas_parser_api": {
"command": "node",
"args": ["/path/to/local/cas-parser-node/packages/mcp-server"],
"cas_parser_node_api": {
"command": "npx",
"args": ["-y", "cas-parser-mcp"],
"env": {
"CAS_PARSER_API_KEY": "My API Key",
"CAS_PARSER_ENVIRONMENT": "production"
Expand All @@ -51,6 +36,29 @@ For clients with a configuration JSON, it might look something like this:
}
```

### Cursor

If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables
in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server.

[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=cas-parser-mcp&config=eyJuYW1lIjoiY2FzLXBhcnNlci1tY3AiLCJ0cmFuc3BvcnQiOiJodHRwIiwidXJsIjoiaHR0cHM6Ly9jYXMtcGFyc2VyLnN0bG1jcC5jb20iLCJoZWFkZXJzIjp7IngtYXBpLWtleSI6Ik15IEFQSSBLZXkifX0)

### VS Code

If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables
in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration.

[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22cas-parser-mcp%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fcas-parser.stlmcp.com%22%2C%22headers%22%3A%7B%22x-api-key%22%3A%22My%20API%20Key%22%7D%7D)

### Claude Code

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
environment variables in Claude Code's `.claude.json`, which can be found in your home directory.

```
claude mcp add cas_parser_mcp_api --header "x-api-key: My API Key" --transport http https://cas-parser.stlmcp.com
```

## Code Mode

This MCP server is built on the "Code Mode" tool scheme. In this MCP Server,
Expand Down Expand Up @@ -82,7 +90,7 @@ A configuration JSON for this server might look like this, assuming the server i
```json
{
"mcpServers": {
"cas_parser_api": {
"cas_parser_node_api": {
"url": "http://localhost:3000",
"headers": {
"x-api-key": "My API Key"
Expand Down
8 changes: 4 additions & 4 deletions packages/mcp-server/build
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ done
# and does a few other minor things
PKG_JSON_PATH=../../packages/mcp-server/package.json node ../../scripts/utils/make-dist-package-json.cjs > dist/package.json

# updates the `cas-parser` dependency to point to NPM
# updates the `cas-parser-node` dependency to point to NPM
node scripts/postprocess-dist-package-json.cjs

# build to .js/.mjs/.d.ts files
Expand All @@ -32,7 +32,7 @@ chmod +x dist/index.js
DIST_PATH=./dist PKG_IMPORT_PATH=cas-parser-mcp/ node ../../scripts/utils/postprocess-files.cjs

# mcp bundle
rm -rf dist-bundle cas_parser_api.mcpb; mkdir dist-bundle
rm -rf dist-bundle cas_parser_node_api.mcpb; mkdir dist-bundle

# copy package.json
PKG_JSON_PATH=../../packages/mcp-server/package.json node ../../scripts/utils/make-dist-package-json.cjs > dist-bundle/package.json
Expand All @@ -48,9 +48,9 @@ cd ..
# pack bundle
cp manifest.json dist-bundle

npx mcpb pack dist-bundle cas_parser_api.mcpb
npx mcpb pack dist-bundle cas_parser_node_api.mcpb

npx mcpb sign cas_parser_api.mcpb --self-signed
npx mcpb sign cas_parser_node_api.mcpb --self-signed

# clean up
rm -rf dist-bundle
Loading