Skip to content

Conversation

@Zhianii
Copy link
Contributor

@Zhianii Zhianii commented Sep 28, 2025

Fixes #PCIP-6 Implement the MCP for Pulsar Admin Tool
Main Issue: #PCIP-6 Implement the MCP for Pulsar Admin Tool

Motivation

This PR introduces the MCP (Model Context Protocol) server implementation for Pulsar Admin operations.
The motivation is to enable AI assistants (such as Claude Desktop) to interact with Apache Pulsar clusters using natural language.
Through MCP, Pulsar administration capabilities are exposed via a standardized protocol, improving automation and intelligent integration.

Modifications

  • Added MCP server layer: StdioMCPServer and HttpMCPServer, supporting STDIO and HTTP Streaming transports
  • Implemented PulsarClientManager to manage the lifecycle of PulsarAdmin and PulsarClient, with lazy initialization and thread safety
  • Developed 70 MCP tool commands, covering:
    • Cluster / Tenant / Namespace / Topic / Subscription management
    • Schema operations
    • Monitoring and backlog analysis
    • Message send and receive
  • Introduced BasePulsarTools base class for parameter validation, error handling, and response encapsulation
  • Enhanced documentation with Quick Start, FAQ, and natural language interaction demos (README)

Verifying this change

  • Verified in local Standalone Pulsar environment (pulsar://localhost:6650, http://localhost:8080)
  • Tested both transport modes:
    • STDIO mode: Successfully integrated with Claude Desktop
    • HTTP mode: Server responded correctly at /mcp
  • Example validation:
    • Successfully executed list-tenants, create-namespace, get-topic-stats, etc.
    • Verified schema upload and compatibility checks
    • Validated backlog analysis and health check tools

(This change has been tested through new integration tests and validated against a real Pulsar cluster.)

@Denovo1998
Copy link
Contributor

@Zhianii It is not necessary to upload the target directory.

@liangyepianzhou
Copy link
Contributor

@Zhianii please use english commit messages.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a Model Context Protocol (MCP) server for Apache Pulsar Admin operations, enabling AI assistants to manage Pulsar clusters through natural language. The implementation provides both HTTP and STDIO transport modes and exposes 70 administrative tool commands across cluster, tenant, namespace, topic, subscription, message, schema, and monitoring categories.

Key changes:

  • New pulsar-admin-mcp-contrib module with MCP server implementations supporting HTTP streaming and STDIO transports
  • 70 tool commands covering comprehensive Pulsar admin operations organized into 8 functional categories
  • Lifecycle management through PulsarClientManager with thread-safe lazy initialization for PulsarAdmin and PulsarClient

Reviewed Changes

Copilot reviewed 31 out of 33 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
pom.xml Adds pulsar-admin-mcp-contrib module to parent POM
pulsar-admin-mcp-contrib/pom.xml Maven configuration with MCP SDK, Pulsar client dependencies and Spring Boot setup
pulsar-admin-mcp-contrib/src/main/java/org/apache/pulsar/admin/mcp/Main.java Application entry point that parses CLI options and launches transport layer
pulsar-admin-mcp-contrib/src/main/java/org/apache/pulsar/admin/mcp/client/PulsarClientManager.java Manages PulsarAdmin and PulsarClient lifecycle with thread-safe initialization
pulsar-admin-mcp-contrib/src/main/java/org/apache/pulsar/admin/mcp/config/PulsarMCPCliOptions.java CLI options parser supporting transport type and port configuration
pulsar-admin-mcp-contrib/src/main/java/org/apache/pulsar/admin/mcp/transport/*.java Transport layer implementations for HTTP and STDIO modes with tool registration
pulsar-admin-mcp-contrib/src/main/java/org/apache/pulsar/admin/mcp/tools/*.java Tool implementations for cluster, tenant, namespace, topic, subscription, message, schema, and monitoring operations
pulsar-admin-mcp-contrib/src/main/resources/application.yml Spring Boot configuration for MCP server, Pulsar connections, and feature flags
pulsar-admin-mcp-contrib/README.md Comprehensive documentation with quick start guide, configuration examples, and usage demos
pcip/picp-6.md PCIP proposal document describing architecture and design decisions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@liangyepianzhou
Copy link
Contributor

@Zhianii Thank you for your tremendous contribution.
I wonder if it would be convenient for you to refer to this and add some unit tests?

@RobertIndie RobertIndie requested a review from Copilot October 29, 2025 12:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 37 out of 39 changed files in this pull request and generated 17 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RobertIndie RobertIndie merged commit f45ee46 into apache:main Oct 31, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants