Chinakeyboardman opened a new pull request, #303:
URL: https://github.com/apache/pulsar-client-python/pull/303

   ### Motivation
   
   Closes #302.
   
   The `examples/` directory covers basic producer/consumer, async, and RPC 
patterns. This PR adds an MCP (Model Context Protocol) server example that 
allows AI agents (Cursor, Claude Desktop, etc.) to interact with Pulsar topics 
via natural language.
   
   MCP is the [emerging open standard](https://modelcontextprotocol.io/) for 
connecting LLM-based tools to external data sources. Having an official example 
in this repository makes Pulsar more accessible to the growing AI agent 
ecosystem.
   
   ### Modifications
   
   Adds `examples/mcp_server.py` — a standalone MCP server that exposes three 
tools:
   
   | Tool | Description |
   |------|-------------|
   | `pulsar_publish` | Publish a message to a topic (supports properties, 
partition key, delayed delivery) |
   | `pulsar_consume` | Consume and auto-acknowledge messages from a 
subscription |
   | `pulsar_peek` | Read messages via Reader without affecting consumer state |
   
   The example uses the official [MCP Python 
SDK](https://github.com/modelcontextprotocol/python-sdk) (`from 
mcp.server.fastmcp import FastMCP`). The `mcp` package is only needed at 
runtime for this example and is **not** added to the project's `setup.py`.
   
   ### Verifying this change
   
   The example is a standalone script with no effect on existing code or tests.
   
   ```bash
   pip install "mcp[cli]" pulsar-client
   PULSAR_BROKER_URL=pulsar://localhost:6650 python3 examples/mcp_server.py
   ```
   
   Configure in Cursor (`~/.cursor/mcp.json`):
   
   ```json
   {
     "mcpServers": {
       "pulsar": {
         "command": "python3",
         "args": ["examples/mcp_server.py"],
         "env": {
           "PULSAR_BROKER_URL": "pulsar://localhost:6650"
         }
       }
     }
   }
   ```
   
   ### Does this pull request potentially affect one of the following parts?
   
   - [ ] Dependencies
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The wire protocol
   - [ ] The Python client
   - [ ] Anything else
   
   ### Documentation
   
   - [ ] `doc-required` — no doc changes needed, this is a self-contained 
example
   - [x] `doc-not-needed`
   
   Made with [Cursor](https://cursor.com)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to