Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/corsair/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { CorsairClientError, createCorsairClient } from './client';
export type { ResolveConnectLinkResult } from './core';
export {
AuthMissingError,
assertReadonlyAllowed,
createCorsair,
PermissionRequiredError,
ReadonlyForbiddenError,
Expand Down
24 changes: 24 additions & 0 deletions packages/mcp/__mocks__/corsair.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { AsyncLocalStorage } from 'node:async_hooks';

const readonlyScope = new AsyncLocalStorage<true>();

export const runReadonly = <T>(fn: () => T): T => {
return readonlyScope.run(true, fn);
};

export class AuthMissingError extends Error {}
export class PermissionRequiredError extends Error {}
export class ReadonlyForbiddenError extends Error {
constructor() {
super('ReadonlyForbiddenError');
this.name = 'ReadonlyForbiddenError';
}
}

export const assertReadonlyAllowed = (_path: string, _type: string) => {
if (readonlyScope.getStore()) {
throw new ReadonlyForbiddenError();
}
};

export const listOperations = (_corsair: any) => [];
40 changes: 40 additions & 0 deletions packages/mcp/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>'],
testMatch: ['**/tests/**/*.test.ts', '**/*.test.ts'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
transform: {
'^.+\\.ts$': [
'ts-jest',
{
useESM: true,
tsconfig: {
esModuleInterop: true,
allowSyntheticDefaultImports: true,
verbatimModuleSyntax: false,
module: 'ESNext',
moduleResolution: 'Bundler',
types: ['node', 'jest'],
},
},
],
'.*\\.js$': [
'ts-jest',
{
useESM: true,
tsconfig: {
esModuleInterop: true,
allowSyntheticDefaultImports: true,
},
},
],
},
moduleNameMapper: {
'^corsair$': '<rootDir>/__mocks__/corsair.ts',
'^(\\.\\.?/.*)\\.js$': '$1',
},
extensionsToTreatAsEsm: ['.ts'],
testTimeout: 30000,
verbose: true,
};
6 changes: 5 additions & 1 deletion packages/mcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"scripts": {
"build": "tsup && tsc -p tsconfig.build.json",
"build:watch": "tsup --watch",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"test": "jest"
},
"dependencies": {
"@ai-sdk/mcp": "^1.0.0",
Expand Down Expand Up @@ -55,7 +56,10 @@
"devDependencies": {
"@anthropic-ai/sdk": "^0.78.0",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.14",
"@types/node": "^22.0.0",
"jest": "^29.7.0",
"ts-jest": "^29.4.9",
"tsup": "^8.0.1",
"typescript": "^5.8.0"
},
Expand Down
Loading
Loading