Skip to content

Commit e1366aa

Browse files
committed
feat: add initial version
0 parents  commit e1366aa

27 files changed

+8680
-0
lines changed

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: CI
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
lint-test:
11+
name: 🚀 Lint and test
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 5
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: lts/*
19+
cache: npm
20+
- name: 📥 Install dependencies
21+
run: npm install
22+
- name: 💅 Lint code style
23+
run: npm run lint
24+
- name: 💻 Build
25+
run: npm run build
26+
27+
publish:
28+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
29+
name: 📦 Publish
30+
runs-on: ubuntu-latest
31+
needs: lint-test
32+
timeout-minutes: 5
33+
permissions:
34+
# Needed by googleapis/release-please-action@v4
35+
contents: write
36+
pull-requests: write
37+
# Needed by `npm publish --provenance`
38+
id-token: write
39+
steps:
40+
- name: 🍄 Bump package version, create GitHub release, and update changelog
41+
uses: googleapis/release-please-action@v4
42+
id: release
43+
- uses: actions/checkout@v4
44+
if: ${{ steps.release.outputs.release_created }}
45+
- uses: actions/setup-node@v4
46+
if: ${{ steps.release.outputs.release_created }}
47+
with:
48+
node-version: lts/*
49+
cache: npm
50+
registry-url: https://registry.npmjs.org
51+
- name: 🚀 Publish to npm
52+
if: ${{ steps.release.outputs.release_created }}
53+
run: |
54+
npm install
55+
npm run build --if-present
56+
npm publish --provenance
57+
env:
58+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.0.1"
3+
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Changelog

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# @codelytv/mcp-test-client
2+
3+
A TypeScript test client for Model Context Protocol (MCP) servers that provides a convenient way to test MCP functionality in your test suites.
4+
5+
## Installation
6+
7+
```bash
8+
npm install --save-dev @codelytv/mcp-test-client
9+
```
10+
11+
## Usage
12+
13+
### Basic Example
14+
15+
```typescript
16+
import { McpTestClient } from '@codelytv/mcp-test-client';
17+
18+
const mcpClient = new McpTestClient("stdio", [
19+
"npx",
20+
"ts-node",
21+
"./src/app/mcp/server.ts",
22+
]);
23+
24+
await mcpClient.connect();
25+
26+
// List available tools
27+
const tools = await mcpClient.listTools();
28+
console.log('Available tools:', tools.names());
29+
30+
// Call a tool
31+
const response = await mcpClient.callTool('search-course-by-id', { id: 'course-123' });
32+
33+
// List resources
34+
const resources = await mcpClient.listResources();
35+
console.log('Available resources:', resources.uris());
36+
37+
// Read a resource
38+
const resource = await mcpClient.readResource('courses://all');
39+
40+
await mcpClient.disconnect();
41+
```
42+
43+
### HTTP Transport
44+
45+
```typescript
46+
const mcpClient = new McpTestClient("http", ["http://localhost:3000/mcp"]);
47+
```
48+
49+
## API
50+
51+
### McpTestClient
52+
53+
The main client class for interacting with MCP servers.
54+
55+
#### Constructor
56+
57+
- `new McpTestClient(transport: "stdio" | "http", args: string[])`
58+
59+
#### Methods
60+
61+
- `connect()` - Connect to the MCP server
62+
- `disconnect()` - Disconnect from the MCP server
63+
- `listTools()` - List available tools
64+
- `callTool(name: string, args?: Record<string, unknown>)` - Call a tool
65+
- `listResources()` - List available resources
66+
- `readResource(uri: string)` - Read a resource
67+
- `listResourceTemplates()` - List resource templates
68+
- `completeResourceTemplateParam(uri: string, paramName: string, textToComplete: string)` - Complete resource template parameters
69+
- `listPrompts()` - List available prompts
70+
- `getPrompt(name: string, args?: Record<string, unknown>)` - Get a prompt
71+
72+
## License
73+
74+
MIT

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintConfigCodely from "eslint-config-codely";
2+
3+
export default [...eslintConfigCodely.ts];

0 commit comments

Comments
 (0)