Skip to content

Conversation

@ibakshay
Copy link
Contributor

@ibakshay ibakshay commented Dec 19, 2025

Summary

  • Migrates from unofficial MCP library to official modelcontextprotocol/go-sdk
  • Refactors CLI architecture to use Cobra with explicit stdio and http subcommands
  • Adds file-based logging capability and improves server lifecycle management with proper signal handling

Tested locally and the implementation works as expected.

closes #54

@ibakshay ibakshay force-pushed the ibakshay/switch-to-official-go-sdk branch 2 times, most recently from 9bcce74 to f7af98a Compare December 19, 2025 22:38
@ibakshay ibakshay marked this pull request as draft January 5, 2026 16:35
@ibakshay ibakshay requested a review from zhuje January 6, 2026 12:26
@ibakshay ibakshay marked this pull request as ready for review January 6, 2026 12:26
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>
ibakshay and others added 9 commits January 6, 2026 15:56
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>
@ibakshay ibakshay force-pushed the ibakshay/switch-to-official-go-sdk branch from b7267b0 to 75d8db5 Compare January 6, 2026 14:57
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Copy link
Member

@Nexucis Nexucis left a 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
Copy link
Member

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() {
Copy link
Member

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]) {
Copy link
Member

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.

Copy link
Member

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

Copy link
Member

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]) {
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

@Nexucis Nexucis Jan 6, 2026

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.

@Nexucis Nexucis changed the title Ibakshay/switch to official go sdk Change: switch to official mcp go sdk Jan 6, 2026
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.

Migrate to official go-sdk for MCP Server

3 participants