A Model Context Protocol (MCP) server for Apache Pulsar that provides tools to interact with Pulsar clusters through MCP-compatible clients.
A Model Context Protocol (MCP) server for Apache Pulsar that provides tools to interact with Pulsar clusters through MCP-compatible clients.
git clone <repository-url>
cd pulsar-mcp-server
pip install -r requirements.txt
pip install -e .
pip install pulsar-mcp-server
After installation, you can run the server using:
pulsar-mcp-server
The server will start and listen for MCP requests via stdio.
from pulsar_mcp_server import main
## Run the server
main()
In your ~/.cursor/mcp.json file, add the following:
"pulsar": {
"command": "pulsar-mcp-server",
"env": {
"PULSAR_SERVICE_URL": "pulsar://localhost:6650",
"PULSAR_WEB_SERVICE_URL": "http://localhost:8080"
}
}
The server can be configured using environment variables or a .env file:
## Pulsar connection settings
PULSAR_SERVICE_URL=pulsar://localhost:6650
PULSAR_WEB_SERVICE_URL=http://localhost:8080
## Topic and subscription settings
TOPIC_NAME=my-topic
SUBSCRIPTION_NAME=pulsar-mcp-subscription
SUBSCRIPTION_TYPE=Shared
IS_TOPIC_READ_FROM_BEGINNING=false
## Authentication (optional)
PULSAR_TOKEN=your-jwt-token
PULSAR_TLS_TRUST_CERTS_FILE_PATH=/path/to/certs
PULSAR_TLS_ALLOW_INSECURE_CONNECTION=false
Publish a message to a Pulsar topic.
Parameters:
topic (string, required): The Pulsar topic to publish tomessage (string, required): The message content to publishproperties (object, optional): Message properties as key-value pairsConsume messages from a Pulsar topic.
Parameters:
topic (string, required): The Pulsar topic to consume fromsubscription_name (string, required): The subscription namemax_messages (integer, optional): Maximum number of messages to consume (default: 10)Create a new Pulsar topic.
Parameters:
topic (string, required): Name of the topic to createpartitions (integer, optional): Number of partitions (default: 1)Delete an existing Pulsar topic.
Parameters:
topic (string, required): Name of the topic to deleteList all topics in the Pulsar cluster.
Parameters: None
Get statistics and metadata about a topic.
Parameters:
topic (string, required): Name of the topic to get stats forpulsar-mcp-server/
├── src/
│ └── pulsar_mcp_server/
│ ├── __init__.py # Package entry point
│ ├── server.py # MCP server implementation
│ ├── pulsar_connector.py # Pulsar client wrapper
│ └── settings.py # Configuration settings
├── pyproject.toml # Project configuration
├── requirements.txt # Dependencies
├── test_server.py # Test script
└── README.md # This file
Run the test script to verify the server functionality:
python test_server.py
You can also run Pulsar locally using Docker for testing:
## Start Pulsar standalone
docker run -it -p 6650:6650 -p 8080:8080 apachepulsar/pulsar:latest bin/pulsar standalone
mcp>=1.1.0,<2.0: Model Context Protocol librarypulsar-client>=3.4.0: Apache Pulsar Python clientpydantic>=2.10.3: Data validation and settings managementpydantic-settings>=2.6.1: Settings management for PydanticMIT License
For issues and questions, please open an issue on the GitHub repository.