WebRTC Transport for Model Context Protocol
Project description
WebRTC Transport for Model Context Protocol
The Model Context Protocol (MCP) is an open standard for connecting AI applications to external systems, such as tools and data sources. It defines several transport mechanisms for client-server communication, including STDIO (over standard input/output) and Streamable HTTP (for web-based streaming).
However, there are scenarios—such as in browser environments or firewalled networks—where neither STDIO nor Streamable HTTP can effectively connect an MCP client to an MCP server. In these cases, WebRTC provides a peer-to-peer alternative, leveraging real-time communication capabilities, provided a signaling connection (e.g., via WebSockets or another channel) is established between the parties.
This repository implements a WebRTC-based transport layer compatible with the MCP specification, enabling seamless integration in constrained networking setups.
Installation
pip install mcp-webrtc
Usage
Server
from mcp_webrtc import webrtc_server_transport
from aiortc.contrib.signaling import TcpSocketSignaling
from mcp.server.lowlevel import Server
from mcp.types import Tool
app = Server("mcp-greeter")
@app.list_tools()
async def list_tools() -> list[Tool]:
return [
Tool(
name="greet",
description="Greets the caller",
inputSchema={
"type": "object",
"required": [],
"properties": {},
},
)
]
async with webrtc_server_transport(TcpSocketSignaling("localhost", 8000)) as (read, write):
await app.run(
read, write, app.create_initialization_options()
)
Client
from mcp import ClientSession
from mcp_webrtc import webrtc_client_transport
from aiortc.contrib.signaling import TcpSocketSignaling
async with (
webrtc_client_transport(TcpSocketSignaling("localhost", 8000)) as (
read,
write,
),
ClientSession(read, write) as session,
):
await session.initialize()
result = await session.list_tools()
print(result.tools)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_webrtc-0.1.0.tar.gz.
File metadata
- Download URL: mcp_webrtc-0.1.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33915c07a15ec53b6434e19ffe1928468f9beb0978f274e82b27d704b797380c
|
|
| MD5 |
6fedd33c56e5b818943f44ab957f1d2f
|
|
| BLAKE2b-256 |
083e825d886ad3d3b865064755d614fd4c5d1f69140dc41879a95f0aeaca300d
|
Provenance
The following attestation bundles were made for mcp_webrtc-0.1.0.tar.gz:
Publisher:
release.yml on pilartomas/mcp-webrtc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_webrtc-0.1.0.tar.gz -
Subject digest:
33915c07a15ec53b6434e19ffe1928468f9beb0978f274e82b27d704b797380c - Sigstore transparency entry: 607480085
- Sigstore integration time:
-
Permalink:
pilartomas/mcp-webrtc@b02457c7bf4406df46e82547abb7c531ce2c3d02 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/pilartomas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b02457c7bf4406df46e82547abb7c531ce2c3d02 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_webrtc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_webrtc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9177b020c7f874d6a38b541dc8d59d2d2fd06bb54be00f6f8e16cd440b0a301
|
|
| MD5 |
97d8b9d51fe3bbcaf293f37a65ba611c
|
|
| BLAKE2b-256 |
baa9400ce55a4f886160f287d8327fc2ed2d9446da6fd25f499f4f6675c465ef
|
Provenance
The following attestation bundles were made for mcp_webrtc-0.1.0-py3-none-any.whl:
Publisher:
release.yml on pilartomas/mcp-webrtc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_webrtc-0.1.0-py3-none-any.whl -
Subject digest:
e9177b020c7f874d6a38b541dc8d59d2d2fd06bb54be00f6f8e16cd440b0a301 - Sigstore transparency entry: 607480088
- Sigstore integration time:
-
Permalink:
pilartomas/mcp-webrtc@b02457c7bf4406df46e82547abb7c531ce2c3d02 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/pilartomas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b02457c7bf4406df46e82547abb7c531ce2c3d02 -
Trigger Event:
release
-
Statement type: