-
Notifications
You must be signed in to change notification settings - Fork 5
Change: switch to official mcp go sdk #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9bcce74 to
f7af98a
Compare
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
…ng tool Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
…ndling Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
…ganization Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
…project by name Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v5...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Bumps golang from 1.25.4 to 1.25.5. --- updated-dependencies: - dependency-name: golang dependency-version: 1.25.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Augustin Husson <augustin.husson@amadeus.com> Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
[ignore] align the way to build binaries and docker images Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Bumps the gomod group with 1 update in the / directory: [github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go). Updates `github.com/mark3labs/mcp-go` from 0.43.0 to 0.43.2 - [Release notes](https://github.com/mark3labs/mcp-go/releases) - [Commits](mark3labs/mcp-go@v0.43.0...v0.43.2) --- updated-dependencies: - dependency-name: github.com/mark3labs/mcp-go dependency-version: 0.43.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: gomod ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
b7267b0 to
75d8db5
Compare
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Nexucis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding few suggestions
|
|
||
| .PHONY: permcp | ||
| permcp: | ||
| $(GO) build -o bin/permcp ./cmd/permcp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the need to have the same binary built in two different name ?
| } | ||
| ) | ||
|
|
||
| func init() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should avoid using the init function, there are really few cases where you actually needed. And I don't see here the requirement to use it.
| Project string `json:"project" jsonschema:"Project name to list dashboards from"` | ||
| } | ||
|
|
||
| func ListDashboards(client apiClient.ClientInterface) (*mcp.Tool, mcp.ToolHandlerFor[ListNewDashboardsInput, any]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could actually create a dedicated package for each resources. Doing that will give you the possibility to remove the name of the resource in the function name. That's how Go has been designed, package oriented.
For example if you have package dashboard, then you can expose the following function:
func List(client apiClient.ClientInterface) (*mcp.Tool, mcp.ToolHandlerFor[ListNewDashboardsInput, any]) { }
func GetByName(client apiClient.ClientInterface) (*mcp.Tool, mcp.ToolHandlerFor[GetDashboardByNameInput, any]) {}
func Create(client apiClient.ClientInterface) (*mcp.Tool, mcp.ToolHandlerFor[CreateDashboardInput, any]) {}This is more elegant and will give clear indication about the goal of each packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and if you think about what your package should expose, then you could think it should actually only expose a single function providing the list of associated tools.
So instead of calling individually each function, one by one, you can declare a single function per package New providing the list of function.
package tool
type Tool struct {
MCPTool: *mcp.Tool
Handler: mcp.ToolHandlerFor[any, any]
// IsWriteTool tells you if the current tool will need write access
IsWriteTool: boolean
}
package dashboard
func New(client apiClient.ClientInterface) []*tool.Tool {
return []*tool.Tool {
list(client), getByName(client), create(client)
}
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then if you use this way to structure your code, the function
registerTools() will simply be:
func (s *Server) registerTools() {
var persesTools []*tool.Tools
persesTools = append(persesTools, dashboards.New())
persesTools = append(persesTools, globaldatasources.New())
persesTools = append(persesTools, roles.New())
for _, t := range persesTools {
if s.cfg.ReadOnly && !t.IsWriteTool {
continue
}
mcp.AddTool(s.mcpServer, t.MCPTool, t.Handler)
}
}Which I believe is cleaner than the current code
| if err != nil { | ||
| return nil, fmt.Errorf("error retrieving global datasources: %w", err) | ||
| } | ||
| func ListGlobalDatasources(client apiClient.ClientInterface) (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename this file as globaldatasources.go as it does not provide the functions managing the Datasources but the GlobalDatasources
| // Add write tools here | ||
| if !s.cfg.ReadOnly { | ||
| dashboardCreateTool, dashboardCreateHandler := tools.CreateNewDashboard(s.persesClient) | ||
| mcp.AddTool(s.mcpServer, dashboardCreateTool, dashboardCreateHandler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case, you cannot use the function to create a project which is used above (outside of this condition)
| .PHONY: build | ||
| build: | ||
| go build -o bin/ | ||
| $(GO) build -o bin/perses-mcp-server ./cmd/permcp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the file main.go has been moved to another package, you need to update the file .goreleaser.base.yaml to change the location of this file.
Otherwise the CI will fail building the binary.
Summary
modelcontextprotocol/go-sdkTested locally and the implementation works as expected.
closes #54