Skip to content

Add Typescript bindings crate, FFI, workflow, and examples for RMCP Rust SDK #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tarunanand-dev
Copy link

Overview

TypeScript Bindings for RMCP

This PR adds TypeScript bindings for the Rust Model Context Protocol (RMCP) SDK, providing a native TypeScript/JavaScript interface for interacting with RMCP services.

Changes

Core TypeScript Bindings

  • Added TypeScript bindings crate under bindings/typescript
  • Implemented core client functionality with SSE transport support
  • Added comprehensive type definitions for RMCP models and capabilities
  • Added build system integration with build.rs

Motivation and Context

How Has This Been Tested?

  • Added TypeScript test suite
  • Included example client implementation for verification

Breaking Changes

None

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Example Client

  • Added a new example client in bindings/typescript/examples/clients
  • Implemented SSE client example with TypeScript
  • Added necessary package configuration and TypeScript setup

Integration

  • Updated root Cargo.toml to include TypeScript bindings
  • Added TypeScript-specific build and test configurations

Documentation

  • Added TypeScript-specific documentation
  • Included example usage in the client implementation

TypeScript Bindings Setup & Example Usage

Prerequisites

  • Rust (latest stable, with cargo)
  • Node.js (latest LTS, with npm)
  • TypeScript (install via npm install -g typescript)

Build the TypeScript Bindings

  1. Navigate to the TypeScript bindings directory:
    cd bindings/typescript
  2. Install dependencies and build the project:
    npm install
    npm run build

Note on Cargo.toml

If you encounter an error indicating that the Cargo.toml of bindings/python is not present in the root Cargo.toml, and you don't want to build Python and TypeScript together, you can edit the root Cargo.toml to remove the Python bindings (bindings/python) entry.

Run the Rust Server

In a separate terminal, start the Rust SDK server (example using the rmcp crate):

cd examples/servers
cargo run --example servers_axum

Link the Module Locally

If the rmcp-typescript module is not published to npm, you can link it locally:

  1. Navigate to the TypeScript bindings directory:
    cd bindings/typescript
  2. Link the module:
    npm link
  3. Navigate to the examples/clients directory and link the module:
    cd examples/clients
    npm link rmcp-typescript

Run the TypeScript SSE Client Example

With the server running, in another terminal:

cd bindings/typescript/examples/clients/src
npx tsx sse.ts

This will connect to the running Rust server and demonstrate the SSE client functionality.

@tarunanand-dev tarunanand-dev changed the title Bindings typescript Add Typescript bindings crate, FFI, workflow, and examples for RMCP Rust SDK May 17, 2025
@4t145
Copy link
Collaborator

4t145 commented May 17, 2025

For #172 and this #183, I am sorry that I don't think I can maintain those bindings in the future. So how about this, you create a repository and maintain those yourself, we add a link to your repository in readme.

cc @jokemanfire

@reneleonhardt
Copy link

Wow, amazing work @tarunanand-dev! 🚀

@jokemanfire
Copy link
Collaborator

jokemanfire commented May 18, 2025

For #172 and this #183, I am sorry that I don't think I can maintain those bindings in the future. So how about this, you create a repository and maintain those yourself, we add a link to your repository in readme.

I think it is better to use a separate repository for maintenance.That way, the existing rust-sdk target will not be modified and the maintenance effort will not increase.

@tarunanand-dev
Copy link
Author

Wow, amazing work @tarunanand-dev! 🚀

Thanks @reneleonhardt Appreciate the feedback.

@tarunanand-dev
Copy link
Author

For #172 and this #183, I am sorry that I don't think I can maintain those bindings in the future. So how about this, you create a repository and maintain those yourself, we add a link to your repository in readme.

I think it is better to use a separate repository for maintenance.That way, the existing rust-sdk target will not be modified and the maintenance effort will not increase.

Ok @jokemanfire thanks for the feedback. I will keep this PR open around for some more time as I gather feedback from other contributors and will then move it out.

@jokemanfire
Copy link
Collaborator

Feel free to open this pr, and I will try to use it and check it after the rust-sdk publish the first stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants