Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit cef5a3a

Browse files
authored
Merge pull request #19 from runbasehq/dev
v0.1.2
2 parents ef28b32 + d93931d commit cef5a3a

File tree

15 files changed

+405
-67
lines changed

15 files changed

+405
-67
lines changed

.changeset/ninety-terms-kneel.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copy this file to .env and add your API keys
2+
3+
# For Anthropic Claude models
4+
ANTHROPIC_API_KEY=your-anthropic-api-key-here
5+
6+
# For OpenAI models
7+
OPENAI_API_KEY=your-openai-api-key-here

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"check-types": "turbo run check-types",
1010
"version": "pnpm changeset version",
1111
"version:packages": "pnpm changeset version",
12-
"release": "pnpm build && pnpm changeset publish"
12+
"release": "pnpm build && pnpm changeset publish",
13+
"mcp-check": "node packages/mcp-check/bin/mcp-check.cjs"
1314
},
1415
"devDependencies": {
1516
"@changesets/cli": "^2.29.5",
@@ -21,5 +22,8 @@
2122
"packageManager": "pnpm@10.13.1",
2223
"engines": {
2324
"node": ">=20"
25+
},
26+
"dependencies": {
27+
"dotenv": "^16.6.1"
2428
}
2529
}

packages/agents/package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
{
22
"name": "@mcp-check/agents",
33
"private": true,
4+
"type": "module",
5+
"main": "dist/index.js",
46
"exports": {
5-
".": "./src/index.ts"
7+
".": {
8+
"import": "./dist/index.js",
9+
"require": "./dist/index.cjs"
10+
}
611
},
712
"scripts": {
13+
"build": "tsup",
814
"lint": "eslint . --max-warnings 0",
915
"check-types": "tsc --noEmit"
1016
},
1117
"dependencies": {
1218
"@anthropic-ai/sdk": "^0.56.0",
1319
"openai": "^5.10.1"
14-
}
20+
},
21+
"files": [
22+
"dist"
23+
]
1524
}

packages/agents/src/index.ts

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import Anthropic from "@anthropic-ai/sdk";
22
import OpenAI from "openai";
33
import type { ChatModel } from "openai/resources";
44

5-
const anthropic = new Anthropic();
6-
const openai = new OpenAI();
5+
// Only initialize clients if API keys are available
6+
const anthropic = process.env.ANTHROPIC_API_KEY ? new Anthropic() : null;
7+
const openai = process.env.OPENAI_API_KEY ? new OpenAI() : null;
78

89
export type AnthropicModel = Anthropic.Model;
910
export type OpenAIModel = ChatModel;
@@ -25,6 +26,11 @@ export class McpServer {
2526
authorizationToken,
2627
name,
2728
type,
29+
}: {
30+
url: string;
31+
authorizationToken: string;
32+
name: string;
33+
type: string;
2834
}) {
2935
this.url = url;
3036
this.authorizationToken = authorizationToken;
@@ -33,7 +39,6 @@ export class McpServer {
3339
}
3440
}
3541

36-
3742
export class Agents {
3843
private promptText: string = "";
3944
private allowedTools: string[] = [];
@@ -57,14 +62,13 @@ export class Agents {
5762
return this;
5863
}
5964

60-
6165
async execute(): Promise<this> {
6266
if (!this.mcpServer) {
63-
throw new Error('MCP server not set');
67+
throw new Error("MCP server not set");
6468
}
6569

66-
this.executionPromises = this.models.map(async model => {
67-
if (model.startsWith('claude') || model.startsWith('claude-')) {
70+
this.executionPromises = this.models.map(async (model) => {
71+
if (model.startsWith("claude") || model.startsWith("claude-")) {
6872
return this.executeAnthropic(model as AnthropicModel);
6973
} else {
7074
return this.executeOpenAi(model as OpenAIModel);
@@ -80,7 +84,13 @@ export class Agents {
8084

8185
private async executeAnthropic(model: AnthropicModel): Promise<this> {
8286
if (!this.mcpServer) {
83-
throw new Error('MCP server not set');
87+
throw new Error("MCP server not set");
88+
}
89+
90+
if (!anthropic) {
91+
throw new Error(
92+
"Anthropic client not initialized. Please set ANTHROPIC_API_KEY environment variable.",
93+
);
8494
}
8595

8696
const stream = anthropic.beta.messages.stream({
@@ -107,10 +117,16 @@ export class Agents {
107117
const usedTools: string[] = [];
108118

109119
for await (const chunk of stream) {
110-
if (chunk.type === "content_block_delta" && chunk.delta.type === "text_delta") {
120+
if (
121+
chunk.type === "content_block_delta" &&
122+
chunk.delta.type === "text_delta"
123+
) {
111124
content += chunk.delta.text;
112125
process.stdout.write(chunk.delta.text);
113-
} else if (chunk.type === "content_block_start" && chunk.content_block.type === "mcp_tool_use") {
126+
} else if (
127+
chunk.type === "content_block_start" &&
128+
chunk.content_block.type === "mcp_tool_use"
129+
) {
114130
usedTools.push(chunk.content_block.name);
115131
}
116132
}
@@ -123,7 +139,13 @@ export class Agents {
123139

124140
private async executeOpenAi(model: OpenAIModel): Promise<this> {
125141
if (!this.mcpServer) {
126-
throw new Error('MCP server not set');
142+
throw new Error("MCP server not set");
143+
}
144+
145+
if (!openai) {
146+
throw new Error(
147+
"OpenAI client not initialized. Please set OPENAI_API_KEY environment variable.",
148+
);
127149
}
128150

129151
const response = await openai.responses.create({
@@ -135,9 +157,9 @@ export class Agents {
135157
server_label: this.mcpServer.name,
136158
server_url: this.mcpServer.url,
137159
headers: {
138-
"Authorization": `Bearer ${this.mcpServer.authorizationToken}`
139-
}
140-
}
160+
Authorization: `${this.mcpServer.authorizationToken}`,
161+
},
162+
},
141163
],
142164
input: this.promptText,
143165
stream: true,
@@ -146,9 +168,9 @@ export class Agents {
146168
const usedTools: string[] = [];
147169

148170
for await (const chunk of response) {
149-
if (chunk.type === 'response.output_item.added') {
171+
if (chunk.type === "response.output_item.added") {
150172
const item = chunk.item;
151-
if (item.type === 'mcp_call') {
173+
if (item.type === "mcp_call") {
152174
usedTools.push(item.name);
153175
}
154176
}
@@ -159,4 +181,3 @@ export class Agents {
159181
return this;
160182
}
161183
}
162-

packages/agents/tsup.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from "tsup";
2+
3+
export default defineConfig({
4+
entry: ["src/index.ts"],
5+
format: ["cjs", "esm"],
6+
dts: false, // Disable DTS generation temporarily
7+
splitting: false,
8+
sourcemap: true,
9+
clean: true,
10+
external: ["@anthropic-ai/sdk", "openai"],
11+
});

packages/mcp-check/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# mcp-testing-library
22

3+
## 0.1.2
4+
5+
### Patch Changes
6+
7+
- add mcp-check CLI
8+
39
## 0.1.1
410

511
### Patch Changes
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env node
2+
3+
const { spawn } = require('child_process');
4+
const path = require('path');
5+
6+
// Try to find tsx
7+
let tsxPath;
8+
try {
9+
// Try to resolve tsx from this package's node_modules
10+
tsxPath = require.resolve('tsx/dist/cli.mjs');
11+
} catch {
12+
try {
13+
// Try the CLI entry point
14+
tsxPath = require.resolve('tsx/cli');
15+
} catch {
16+
// Try global tsx via npx
17+
console.error('tsx not found. Please install tsx: npm install -g tsx');
18+
process.exit(1);
19+
}
20+
}
21+
22+
// Path to the actual CLI source file
23+
const cliPath = path.join(__dirname, '..', 'src', 'cli.ts');
24+
25+
// Execute tsx with the CLI file and pass through all arguments
26+
const child = spawn('node', [tsxPath, cliPath, ...process.argv.slice(2)], {
27+
stdio: 'inherit',
28+
env: process.env
29+
});
30+
31+
child.on('close', (code) => {
32+
process.exit(code || 0);
33+
});
34+
35+
child.on('error', (err) => {
36+
console.error('Error executing mcp-check:', err);
37+
process.exit(1);
38+
});

packages/mcp-check/package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mcp-check",
33
"module": "index.ts",
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"type": "module",
66
"main": "dist/index.js",
77
"types": "dist/index.d.ts",
@@ -15,7 +15,10 @@
1515
"@anthropic-ai/sdk": "^0.56.0",
1616
"@modelcontextprotocol/sdk": "^1.16.0",
1717
"bun-plugin-dts": "^0.3.0",
18+
"dotenv": "^16.4.7",
19+
"glob": "^11.0.0",
1820
"openai": "^5.10.1",
21+
"tsx": "^4.19.2",
1922
"zod": "^3.24.4"
2023
},
2124
"description": "",
@@ -26,12 +29,17 @@
2629
"require": "./dist/index.cjs"
2730
}
2831
},
32+
"bin": {
33+
"mcp-check": "./bin/mcp-check.cjs"
34+
},
2935
"scripts": {
3036
"build": "tsup",
3137
"prepublishOnly": "pnpm build"
3238
},
3339
"files": [
34-
"dist"
40+
"dist",
41+
"bin",
42+
"src"
3543
],
3644
"publishConfig": {
3745
"access": "public"

0 commit comments

Comments
 (0)