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
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.8.0"
".": "1.9.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml
openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0
config_hash: 4ab3e1ee76a463e0ed214541260ee12e
config_hash: 5509bb7a961ae2e79114b24c381606d4
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.9.0 (2026-02-23)

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

### Features

* **api:** manual updates ([75ec0c8](https://github.com/CASParser/cas-parser-node/commit/75ec0c8875f5ac06ef72fff853114efd020e20e0))

## 1.8.0 (2026-02-23)

Full Changelog: [v1.7.2...v1.8.0](https://github.com/CASParser/cas-parser-node/compare/v1.7.2...v1.8.0)
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

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

It is generated with [Stainless](https://www.stainless.com/).

Expand Down Expand Up @@ -33,7 +33,6 @@ 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
environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production'
});

const response = await client.credits.check();
Expand All @@ -51,7 +50,6 @@ 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
environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production'
});

const response: CasParser.CreditCheckResponse = await client.credits.check();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cas-parser-node",
"version": "1.8.0",
"version": "1.9.0",
"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: 1 addition & 3 deletions packages/mcp-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ You can run the MCP Server directly via `npx`:

```sh
export CAS_PARSER_API_KEY="My API Key"
export CAS_PARSER_ENVIRONMENT="production"
npx -y cas-parser-node-mcp@latest
```

Expand All @@ -28,8 +27,7 @@ For clients with a configuration JSON, it might look something like this:
"command": "npx",
"args": ["-y", "cas-parser-node-mcp"],
"env": {
"CAS_PARSER_API_KEY": "My API Key",
"CAS_PARSER_ENVIRONMENT": "production"
"CAS_PARSER_API_KEY": "My API Key"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/mcp-server/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dxt_version": "0.2",
"name": "cas-parser-node-mcp",
"version": "1.8.0",
"version": "1.9.0",
"description": "The official MCP Server for the Cas Parser API",
"author": {
"name": "Cas Parser",
Expand All @@ -12,7 +12,7 @@
"url": "git+https://github.com/CASParser/cas-parser-node.git"
},
"homepage": "https://github.com/CASParser/cas-parser-node/tree/main/packages/mcp-server#readme",
"documentation": "https://docs.casparser.in",
"documentation": "https://casparser.in/docs",
"server": {
"type": "node",
"entry_point": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cas-parser-node-mcp",
"version": "1.8.0",
"version": "1.9.0",
"description": "The official MCP Server for the Cas Parser API",
"author": "Cas Parser <sameer@casparser.in>",
"types": "dist/index.d.ts",
Expand Down
7 changes: 2 additions & 5 deletions packages/mcp-server/src/code-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,14 @@ export function codeTool({ blockedMethods }: { blockedMethods: SdkMethod[] | und
readEnv('CAS_PARSER_API_KEY') ?? client.apiKey,
'set CAS_PARSER_API_KEY environment variable or provide apiKey client option',
),
CAS_PARSER_BASE_URL:
readEnv('CAS_PARSER_BASE_URL') ?? readEnv('CAS_PARSER_ENVIRONMENT') ?
undefined
: client.baseURL ?? undefined,
CAS_PARSER_BASE_URL: readEnv('CAS_PARSER_BASE_URL') ?? client.baseURL ?? undefined,
}),
},
body: JSON.stringify({
project_name: 'cas-parser',
code,
intent,
client_opts: { environment: (readEnv('CAS_PARSER_ENVIRONMENT') || undefined) as any },
client_opts: {},
} satisfies WorkerInput),
});

Expand Down
4 changes: 1 addition & 3 deletions packages/mcp-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ import { getInstructions } from './instructions';
import { McpOptions } from './options';
import { blockedMethodsForCodeTool } from './methods';
import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from './types';
import { readEnv } from './util';

export const newMcpServer = async (stainlessApiKey: string | undefined) =>
new McpServer(
{
name: 'cas_parser_node_api',
version: '1.8.0',
version: '1.9.0',
},
{
instructions: await getInstructions(stainlessApiKey),
Expand Down Expand Up @@ -65,7 +64,6 @@ export async function initMcpServer(params: {
if (!_client) {
try {
_client = new CasParser({
...{ environment: (readEnv('CAS_PARSER_ENVIRONMENT') || undefined) as any },
logger,
...params.clientOptions,
defaultHeaders: {
Expand Down
36 changes: 5 additions & 31 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ import {
} from './internal/utils/log';
import { isEmptyObj } from './internal/utils/values';

const environments = {
production: 'https://portfolio-parser.api.casparser.in',
environment_1: 'https://client-apis.casparser.in',
environment_2: 'http://localhost:5000',
};
type Environment = keyof typeof environments;

export interface ClientOptions {
/**
* Your API key for authentication.
Expand All @@ -86,16 +79,6 @@ export interface ClientOptions {
*/
apiKey?: string | undefined;

/**
* Specifies the environment to use for the API.
*
* Each environment maps to a different base URL:
* - `production` corresponds to `https://portfolio-parser.api.casparser.in`
* - `environment_1` corresponds to `https://client-apis.casparser.in`
* - `environment_2` corresponds to `http://localhost:5000`
*/
environment?: Environment | undefined;

/**
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
*
Expand Down Expand Up @@ -187,8 +170,7 @@ export class CasParser {
* API Client for interfacing with the Cas Parser API.
*
* @param {string | undefined} [opts.apiKey=process.env['CAS_PARSER_API_KEY'] ?? undefined]
* @param {Environment} [opts.environment=production] - Specifies the environment URL to use for the API.
* @param {string} [opts.baseURL=process.env['CAS_PARSER_BASE_URL'] ?? https://portfolio-parser.api.casparser.in] - Override the default base URL for the API.
* @param {string} [opts.baseURL=process.env['CAS_PARSER_BASE_URL'] ?? https://api.casparser.in] - Override the default base URL for the API.
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
Expand All @@ -210,17 +192,10 @@ export class CasParser {
const options: ClientOptions = {
apiKey,
...opts,
baseURL,
environment: opts.environment ?? 'production',
baseURL: baseURL || `https://api.casparser.in`,
};

if (baseURL && opts.environment) {
throw new Errors.CasParserError(
'Ambiguous URL; The `baseURL` option (or CAS_PARSER_BASE_URL env var) and the `environment` option are given. If you want to use the environment you must pass baseURL: null',
);
}

this.baseURL = options.baseURL || environments[options.environment || 'production'];
this.baseURL = options.baseURL!;
this.timeout = options.timeout ?? CasParser.DEFAULT_TIMEOUT /* 1 minute */;
this.logger = options.logger ?? console;
const defaultLogLevel = 'warn';
Expand All @@ -246,8 +221,7 @@ export class CasParser {
withOptions(options: Partial<ClientOptions>): this {
const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)({
...this._options,
environment: options.environment ? options.environment : undefined,
baseURL: options.environment ? undefined : this.baseURL,
baseURL: this.baseURL,
maxRetries: this.maxRetries,
timeout: this.timeout,
logger: this.logger,
Expand All @@ -264,7 +238,7 @@ export class CasParser {
* Check whether the base URL is set to its default.
*/
#baseURLOverridden(): boolean {
return this.baseURL !== environments[this._options.environment || 'production'];
return this.baseURL !== 'https://api.casparser.in';
}

protected defaultQuery(): Record<string, string | undefined> | undefined {
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '1.8.0'; // x-release-please-version
export const VERSION = '1.9.0'; // x-release-please-version
21 changes: 2 additions & 19 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,30 +322,13 @@ describe('instantiate client', () => {
test('empty env variable', () => {
process.env['CAS_PARSER_BASE_URL'] = ''; // empty
const client = new CasParser({ apiKey: 'My API Key' });
expect(client.baseURL).toEqual('https://portfolio-parser.api.casparser.in');
expect(client.baseURL).toEqual('https://api.casparser.in');
});

test('blank env variable', () => {
process.env['CAS_PARSER_BASE_URL'] = ' '; // blank
const client = new CasParser({ apiKey: 'My API Key' });
expect(client.baseURL).toEqual('https://portfolio-parser.api.casparser.in');
});

test('env variable with environment', () => {
process.env['CAS_PARSER_BASE_URL'] = 'https://example.com/from_env';

expect(
() => new CasParser({ apiKey: 'My API Key', environment: 'production' }),
).toThrowErrorMatchingInlineSnapshot(
`"Ambiguous URL; The \`baseURL\` option (or CAS_PARSER_BASE_URL env var) and the \`environment\` option are given. If you want to use the environment you must pass baseURL: null"`,
);

const client = new CasParser({
apiKey: 'My API Key',
baseURL: null,
environment: 'production',
});
expect(client.baseURL).toEqual('https://portfolio-parser.api.casparser.in');
expect(client.baseURL).toEqual('https://api.casparser.in');
});

test('in request options', () => {
Expand Down