├── .github └── workflows │ └── rust.yml ├── .gitignore ├── Cargo.toml ├── LICENSE ├── README.md ├── flake.lock ├── flake.nix └── src ├── client └── README.md ├── lib.rs ├── server └── README.md └── shared └── README.md /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Build 20 | run: cargo build --verbose 21 | - name: Run tests 22 | run: cargo test --verbose 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | debug/ 4 | target/ 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 8 | Cargo.lock 9 | 10 | # These are backup files generated by rustfmt 11 | **/*.rs.bk 12 | 13 | # MSVC Windows builds of rustc generate these, which store debugging information 14 | *.pdb 15 | 16 | # RustRover 17 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 18 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 19 | # and can be added to the global gitignore or merged into this file. For a more nuclear 20 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 21 | #.idea/ 22 | 23 | # Added by cargo 24 | 25 | /target 26 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "modelcontextprotocol-rust-sdk" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "The UNofficial Rust SDK for Model Context Protocol servers and clients" 6 | license = "MIT" 7 | repository = "https://github.com/jeanlucthumm/modelcontextprotocol-rust-sdk" 8 | readme = "README.md" 9 | keywords = ["modelcontextprotocol", "mcp", "llm", "ai", "protocol"] 10 | categories = ["api-bindings", "development-tools"] 11 | 12 | [dependencies] 13 | serde = "1.0.215" 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Jean-Luc Thumm 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MCP Rust SDK 2 | [![MIT licensed][mit-badge]][mit-url] 3 | [![Specification][spec-badge]][spec-url] 4 | 5 | [mit-badge]: https://img.shields.io/pypi/l/mcp.svg 6 | [mit-url]: https://github.com/jeanlucthumm/modelcontextprotocol-rust-sdk/blob/master/LICENSE 7 | [spec-badge]: https://img.shields.io/badge/spec-spec.modelcontextprotocol.io-blue.svg 8 | [spec-url]: https://spec.modelcontextprotocol.io 9 | 10 | Rust SDK for the Model Context Protocol 11 | 12 | Rust implementation of the [Model Context Protocol](https://modelcontextprotocol.io) (MCP), providing both client and server capabilities for integrating with LLM surfaces. 13 | 14 | > [!WARNING] 15 | > This is a VERY early repo. Open an issue or contact me at jeanlucthumm@gmail.com if you'd like to get involved. Discord coming soon! 16 | 17 | ## Overview 18 | 19 | The Model Context Protocol allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction. This Rust SDK implements the full MCP specification, making it easy to: 20 | 21 | - Build MCP clients that can connect to any MCP server 22 | - Create MCP servers that expose resources, prompts and tools 23 | - Use standard transports like stdio and SSE 24 | - Handle all MCP protocol messages and lifecycle events 25 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "locked": { 5 | "lastModified": 1732521221, 6 | "narHash": "sha256-2ThgXBUXAE1oFsVATK1ZX9IjPcS4nKFOAjhPNKuiMn0=", 7 | "owner": "NixOS", 8 | "repo": "nixpkgs", 9 | "rev": "4633a7c72337ea8fd23a4f2ba3972865e3ec685d", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "NixOS", 14 | "ref": "nixos-unstable", 15 | "repo": "nixpkgs", 16 | "type": "github" 17 | } 18 | }, 19 | "root": { 20 | "inputs": { 21 | "nixpkgs": "nixpkgs" 22 | } 23 | } 24 | }, 25 | "root": "root", 26 | "version": 7 27 | } 28 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "The UNofficial Rust SDK for Model Context Protocol servers and clients"; 3 | 4 | inputs = { 5 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 6 | }; 7 | 8 | outputs = { 9 | self, 10 | nixpkgs, 11 | }: let 12 | systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; 13 | forAllSystems = nixpkgs.lib.genAttrs systems; 14 | in { 15 | devShells = forAllSystems (system: let 16 | pkgs = nixpkgs.legacyPackages.${system}; 17 | in { 18 | default = pkgs.mkShell { 19 | packages = with pkgs; [ 20 | cargo 21 | rustc 22 | openssl 23 | pkg-config 24 | cargo-deny 25 | cargo-edit 26 | cargo-watch 27 | rust-analyzer 28 | ]; 29 | }; 30 | }); 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /src/client/README.md: -------------------------------------------------------------------------------- 1 | # Client SDK 2 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | 2 | 3 | pub fn todo() { 4 | println!("TODO"); 5 | } 6 | -------------------------------------------------------------------------------- /src/server/README.md: -------------------------------------------------------------------------------- 1 | # Server SDK 2 | -------------------------------------------------------------------------------- /src/shared/README.md: -------------------------------------------------------------------------------- 1 | # Shared 2 | 3 | Common modules for server, client, and protocol. 4 | --------------------------------------------------------------------------------