Add MCP server#51
Merged
Merged
Conversation
|
Coverage for this change: 62.4% |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an optional MCP (Management Control Protocol) HTTP endpoint to the pgmanager server, wiring in an MCP server wrapper and exposing initial MCP tools for basic cluster health and role inspection.
Changes:
- Introduces a new
--mcpflag and registers an MCP handler endpoint when enabled. - Adds an
pgmanager/mcppackage implementing an MCP server wrapper plus initialpingandlist_rolestools. - Updates module dependencies to include the MCP/LLM server library and related transitive requirements.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pgmanager/mcp/server.go | New MCP server wrapper and tool adapter implementation. |
| pgmanager/mcp/ping.go | Adds MCP ping tool backed by manager.Ping. |
| pgmanager/mcp/roles.go | Adds MCP list_roles tool backed by manager.GetRole / manager.ListRoles. |
| pgmanager/cmd/server.go | Adds --mcp flag and conditional route registration for the MCP endpoint. |
| go.mod | Adds go-llm dependency and updates indirect requirements. |
| go.sum | Records new/updated dependency checksums. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+74
to
+76
| func (tool *tool) OutputSchema() *jsonschema.Schema { | ||
| return tool.output | ||
| } |
Comment on lines
+39
to
+43
| if len(input) > 0 && string(input) != "null" { | ||
| if err := json.Unmarshal(input, &in); err != nil { | ||
| return nil, err | ||
| } | ||
| } |
Comment on lines
+58
to
+63
| result := make([]*schema.Role, 0, len(list.Body)) | ||
| for i := range list.Body { | ||
| role := list.Body[i] | ||
| result = append(result, &role) | ||
| } | ||
| return ListRolesOutput{Roles: result}, nil |
|
|
||
| // Serve the MCP endpoint | ||
| handler := mcpServer.Handler() | ||
| return router.RegisterPath("/mcp", nil, httprequest.NewPathItem("MCP", "Management Control Protocol endpoint"). |
Comment on lines
+47
to
+50
| // Add tools to the server | ||
| if err := self.AddTools(self.Ping(), self.ListRoles()); err != nil { | ||
| return nil, err | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new MCP (Management Control Protocol) server endpoint to the PostgreSQL manager, allowing programmatic management and health checking of PostgreSQL clusters. It adds the necessary dependencies, command-line flags, server registration logic, and initial MCP tools (Ping and ListRoles) to support this functionality.
Major features and enhancements:
MCP Server Integration:
--mcpcommand-line flag to enable the MCP endpoint in the server (pgmanager/cmd/server.go)./mcpendpoint when enabled, including setup of instructions and tracing.MCP Server and Tool Implementation:
pgmanager/mcp/server.go, integrating with the PostgreSQL manager and registering initial tools.Pingtool to check the health status of the PostgreSQL cluster.ListRolestool to list roles in the PostgreSQL cluster, with optional filtering by role name.Dependency Updates:
go.modwith new dependencies required for MCP, JWT/OAuth, JSON handling, and PostgreSQL management, as well as minor updates to existing indirect dependencies. [1] [2] [3] [4] [5]pgmanager/cmd/server.goto support MCP server integration.These changes lay the groundwork for advanced programmatic management of PostgreSQL clusters via a standardized protocol and make it easy to add further tools to the MCP server in the future.