Chinakeyboardman opened a new issue, #302:
URL: https://github.com/apache/pulsar-client-python/issues/302

   ### Motivation
   
   The `examples/` directory shows basic producer/consumer, async, and RPC 
patterns, but there is no example demonstrating integration with AI agents.
   
   The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) is the 
emerging standard for connecting AI tools (Cursor, Claude Desktop, Windsurf, 
etc.) to external data sources. An MCP server example would allow developers to 
interact with Pulsar topics through natural language, bridging messaging 
infrastructure and the AI agent ecosystem.
   
   ### Proposed Change
   
   Add `examples/mcp_server.py` that exposes three tools via the official MCP 
Python SDK (`pip install mcp`):
   
   | 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 using a Reader without affecting consumer 
state |
   
   The example is a standalone script—`mcp` is only required at runtime for 
this example and is **not** added to the project's `setup.py` dependencies.
   
   ### Configuration
   
   Once configured in an MCP-compatible client (e.g. Cursor 
`~/.cursor/mcp.json`), users can produce and consume Pulsar messages through 
natural language.
   
   ```json
   {
     "mcpServers": {
       "pulsar": {
         "command": "python3",
         "args": ["examples/mcp_server.py"],
         "env": {
           "PULSAR_BROKER_URL": "pulsar://localhost:6650"
         }
       }
     }
   }
   ```
   
   I'm happy to submit a PR for this.


-- 
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