MCP Callback Protocol extension for enabling asynchronous tool callbacks and streaming updates from MCP clients
Project description
MCPC - Model Context Protocol Callback
An extension to the MCP (Model-Context-Protocol) protocol that enables asynchronous real-time callbacks and streaming updates from MCP tools.
What is MCPC?
MCPC is an extension to the MCP protocol, not a replacement. It builds upon the existing MCP infrastructure to add real-time callback capabilities while maintaining full compatibility with standard MCP implementations.
MCPC solves a critical limitation in LLM tool interactions: maintaining conversational flow while running background tasks. It enables:
- Continuous conversation with LLMs during tool execution
- Real-time updates from background processes
- Asynchronous notifications when operations complete
- Support for indefinitely running tasks with streaming updates
Compatibility Matrix
| Feature | Status | Notes |
|---|---|---|
| STDIO Transport | ✅ Implemented | Full support for standard input/output transport |
| SSE Transport | ⚠️ Limited Support | Standard MCP operations only, MCPC features pending |
| MCPC Client → Standard MCP Server | ✅ Implemented | Full backward compatibility |
| Standard MCP Client → MCPC Server | ✅ Implemented | Automatic fallback to synchronous results |
Quick Installation
# With UV (recommended)
uv add mcpc
# With pip
pip install mcpc
Basic Client Usage
# Initialize the MCPC handler
mcpc_handler = MCPCHandler("my-provider")
# Add your event listener for MCPC Message
mcpc_handler.add_event_listener(my_mcpc_listener)
# Wrap the transport with MCPC event listeners
wrapped_transport = await mcpc_handler.wrap_streams(*transport)
# Create a ClientSession with the wrapped transport
session = await ClientSession(*wrapped_transport)
# Initialize MCPC features by checking for MCPC support
mcpc_supported = await mcpc_handler.init_mcpc(session)
if mcpc_supported:
print(f"MCPC protocol v{mcpc_handler.protocol_version} supported")
Basic Server Usage
# Initialize MCPC helper
server = Server(PROVIDER_NAME)
mcpc = MCPCHelper(PROVIDER_NAME, transport_type="stdio")
@server.call_tool()
async def call_tool(name: str, arguments: Dict[str, Any]) -> List[TextContent]:
metadata = arguments.pop("_metadata", {})
session_id = metadata.get("mcpc_session_id", "default")
task_id = metadata.get("mcpc_task_id", str(uuid.uuid4()))
# Handle protocol information request
if name == "_is_mcpc_enabled":
client_info = arguments.get("mcpc_info")
return mcpc.handle_protocol_info_request(client_info)
if name == "process_data":
async def process_data_task():
await mcpc.send(mcpc.create_message(
type="task",
event="update",
tool_name="process_data",
session_id=session_id,
task_id=task_id,
result="Processing data..."
))
await mcpc.send(mcpc.create_message(
type="task",
event="complete",
tool_name="process_data",
session_id=session_id,
task_id=task_id,
result={
YOUR_DATA_OBJECT
}
))
# Start a background task
collected_messages = mcpc.start_task(task_id, process_data_task)
# For standard MCP clients, return collected complete/failed messages
if collected_messages:
return mcpc.messages_to_text_content(collected_messages)
# For MCPC clients, return immediate acknowledgment
response = mcpc.create_message(
type="task",
event="created",
tool_name="process_data",
session_id=session_id,
task_id=task_id,
result=f"Started processing data_id={data_id}. Updates will stream in real-time."
)
return mcpc.messages_to_text_content([response])
Documentation
For detailed documentation, please see:
- Getting Started Guide - Installation and basic usage
- Server Implementation - How to implement MCPC in your server
- API Reference - Detailed API documentation
- Protocol Details - Message structure and protocol information
- Use Cases - Example scenarios and use cases
License
MIT
Project details
Release history Release notifications | RSS feed
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 mcpc-0.2.3.tar.gz.
File metadata
- Download URL: mcpc-0.2.3.tar.gz
- Upload date:
- Size: 36.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cff254c4d951ce5e25471349df326522d2dfa360e1616813a2b276ae22b90dd0
|
|
| MD5 |
fce98754d6d92aca8dc60fd9002f4215
|
|
| BLAKE2b-256 |
54769def84bc02849d8e2f99761447b67402a888d292682c8b6beffeb1862dcb
|
Provenance
The following attestation bundles were made for mcpc-0.2.3.tar.gz:
Publisher:
python-publish.yml on OlaHulleberg/mcpc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcpc-0.2.3.tar.gz -
Subject digest:
cff254c4d951ce5e25471349df326522d2dfa360e1616813a2b276ae22b90dd0 - Sigstore transparency entry: 190994964
- Sigstore integration time:
-
Permalink:
OlaHulleberg/mcpc@b7b8230b6ccf73dc95d7464e3858796d91353465 -
Branch / Tag:
refs/tags/0.2.3 - Owner: https://github.com/OlaHulleberg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b7b8230b6ccf73dc95d7464e3858796d91353465 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcpc-0.2.3-py3-none-any.whl.
File metadata
- Download URL: mcpc-0.2.3-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adb73057224d6badb160d78af901e65f913d529e4e1b4cb7775ed0e05ebccc74
|
|
| MD5 |
391dbf70d1816e3726ec018498c809c7
|
|
| BLAKE2b-256 |
3ed1126a6ee7097c9281fdc095bffc53dd0d056ee332dc0796a8c34205ad888b
|
Provenance
The following attestation bundles were made for mcpc-0.2.3-py3-none-any.whl:
Publisher:
python-publish.yml on OlaHulleberg/mcpc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcpc-0.2.3-py3-none-any.whl -
Subject digest:
adb73057224d6badb160d78af901e65f913d529e4e1b4cb7775ed0e05ebccc74 - Sigstore transparency entry: 190994967
- Sigstore integration time:
-
Permalink:
OlaHulleberg/mcpc@b7b8230b6ccf73dc95d7464e3858796d91353465 -
Branch / Tag:
refs/tags/0.2.3 - Owner: https://github.com/OlaHulleberg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b7b8230b6ccf73dc95d7464e3858796d91353465 -
Trigger Event:
release
-
Statement type: