Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CodelyTV/typescript-mcp-client

Repository files navigation

Codely logo

πŸ”Œ MCP Client

Codely Open Source CodelyTV Courses

A TypeScript test client for Model Context Protocol (MCP) servers that provides a convenient way to test MCP functionality in your test suites.

Take a look, play and have fun with this. Stars are welcome 😊

⬇️ Installation

npm install --save-dev @codelytv/mcp-client

πŸ’» Usage

Basic Example

import { McpClient } from '@codelytv/mcp-client';
const mcpClient = new McpClient("stdio", [
 "npx",
 "ts-node",
 "./src/app/mcp/server.ts",
]);
await mcpClient.connect();
// List available tools
const tools = await mcpClient.listTools();
console.log('Available tools:', tools.names());
// Call a tool
const response = await mcpClient.callTool('search-course-by-id', { id: 'course-123' });
// List resources
const resources = await mcpClient.listResources();
console.log('Available resources:', resources.uris());
// Read a resource
const resource = await mcpClient.readResource('courses://all');
await mcpClient.disconnect();

HTTP Transport

const mcpClient = new McpClient("http", ["http://localhost:3000/mcp"]);

πŸ”‘ API

McpClient

The main client class for interacting with MCP servers.

Constructor

  • new McpClient(transport: "stdio" | "http", args: string[])

Methods

  • connect() - Connect to the MCP server
  • disconnect() - Disconnect from the MCP server
  • listTools() - List available tools
  • callTool(name: string, args?: Record<string, unknown>) - Call a tool
  • listResources() - List available resources
  • readResource(uri: string) - Read a resource
  • listResourceTemplates() - List resource templates
  • completeResourceTemplateParam(uri: string, paramName: string, textToComplete: string) - Complete resource template parameters
  • listPrompts() - List available prompts
  • getPrompt(name: string, args?: Record<string, unknown>) - Get a prompt

πŸ‘Œ Codely Code Quality Standards

Publishing this package we are committing ourselves to the following code quality standards:

  • 🀝 Respect Semantic Versioning: No breaking changes in patch or minor versions
  • 🀏 No surprises in transitive dependencies: Use the bare minimum dependencies needed to meet the purpose
  • 🎯 One specific purpose to meet without having to carry a bunch of unnecessary other utilities
  • βœ… Tests as documentation and usage examples
  • πŸ“– Well documented ReadMe showing how to install and use
  • βš–οΈ License favoring Open Source and collaboration

βš–οΈ License

See LICENSE

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /