Skip to content

Add Python bindings crate, FFI, workflow, and examples for RMCP Rust SDK #172

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 2 commits into
base: main
Choose a base branch
from

Conversation

tarunanand-dev
Copy link

Overview

This PR introduces Python bindings for the RMCP Rust SDK using PyO3, along with a GitHub Actions workflow, tests, and example usage. The bindings enable Python applications to interact with the Rust SDK via FFI, including an example SSE client.

What’s Included
New Rust crate for Python bindings under bindings/python
PyO3-based FFI for seamless Rust ↔ Python integration
Example Python SSE client (bindings/python/examples/clients/src/sse.py)
GitHub Actions workflow for building and testing Python bindings
Tests for Python bindings (bindings/python/tests/)
.gitignore files for Rust and Python artifacts

How Has This Been Tested?

An example working Python client and a few test cases have been added.

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

README: Python Bindings Setup & Example Usage

  1. Prerequisites
    Rust (latest stable, with cargo)
    Python 3.8+ (with pip)
    maturin for building the Python extension (install via pip install maturin)
  2. Build the Python FFI Extension

cd bindings/python
maturin develop # or: maturin build && pip install target/wheels/*.whl

This will compile the Rust FFI library and install the Python package in your environment.

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

cd examples
cargo run --example servers_axum

  1. Run the Python SSE Client Example
    With the server running, in another terminal:

cd bindings/python/examples/clients/src
python sse.py

@reneleonhardt
Copy link

Wow! ❤️

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.

3 participants