Skip to content

Commit 0b22def

Browse files
authored
Merge pull request #13 from perses/ibakshay/add-read-only-tools
feat(add-tools) Add Read-only tools
2 parents 576246d + eda4107 commit 0b22def

File tree

10 files changed

+500
-59
lines changed

10 files changed

+500
-59
lines changed

README.md

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
<h1 align="center">MCP Server for Perses</h1>
44
</div>
55

6+
> [!WARNING]
7+
> This MCP Server is currently in **beta**. Features and tools may change, and stability is not guaranteed. Feedback and contributions are most welcome!
8+
9+
610
## Overview
711

812
The Perses MCP Server is a local [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) Server that enables the LLM hosts(Claude Desktop, VS Code, Cursor) to interact with the Perses Application in a standardized way.
@@ -122,31 +126,54 @@ To integrate the MCP server with VS Code GitHub Copilot, follow these steps:
122126

123127
### Projects
124128

125-
| Tool | Description | Required Parameters |
126-
| ---------------------- | ----------------- | ------------------- |
127-
| `perses_list_projects` | List all projects | - |
129+
| Tool | Description | Required Parameters |
130+
| ---------------------------- | --------------------- | ------------------- |
131+
| `perses_list_projects` | List all projects | - |
132+
| `perses_get_project_by_name` | Get a project by name | `project` |
128133

129134
### Dashboards
130135

131-
| Tool | Description | Required Parameters |
132-
| ------------------------ | ------------------------------------------ | ------------------- |
133-
| `perses_list_dashboards` | List all dashboards for a specific project | `project` |
134-
136+
| Tool | Description | Required Parameters |
137+
| ------------------------------ | ------------------------------------------ | ---------------------- |
138+
| `perses_list_dashboards` | List all dashboards for a specific project | `project` |
139+
| `perses_get_dashboard_by_name` | Get a dashboard by name for a project | `project`, `dashboard` |
135140

136141
### Datasources
137142

138-
| Tool | Description | Required Parameters |
139-
| -------------------------------- | ------------------------------------------- | ------------------- |
140-
| `perses_list_global_datasources` | List all global datasources | - |
141-
| `perses_list_datasources` | List all datasources for a specific project | `project` |
143+
| Tool | Description | Required Parameters |
144+
| --------------------------------------- | ------------------------------------------- | ----------------------- |
145+
| `perses_list_global_datasources` | List all global datasources | - |
146+
| `perses_list_datasources` | List all datasources for a specific project | `project` |
147+
| `perses_get_global_datasource_by_name` | Get a global datasource by name | `datasource` |
148+
| `perses_get_project_datasource_by_name` | Get a project datasource by name | `project`, `datasource` |
149+
150+
### Roles
151+
152+
| Tool | Description | Required Parameters |
153+
| ----------------------------------------- | ------------------------------------- | ------------------------ |
154+
| `perses_list_global_roles` | List all global roles | - |
155+
| `perses_get_global_role_by_name` | Get a global role by name | `role` |
156+
| `perses_list_global_role_bindings` | List all global role bindings | - |
157+
| `perses_get_global_role_binding_by_name` | Get a global role binding by name | `roleBinding` |
158+
| `perses_list_project_roles` | List all roles for a specific project | `project` |
159+
| `perses_get_project_role_by_name` | Get a project role by name | `project`, `role` |
160+
| `perses_list_project_role_bindings` | List all role bindings for a project | `project` |
161+
| `perses_get_project_role_binding_by_name` | Get a project role binding by name | `project`, `roleBinding` |
162+
163+
### Plugins
164+
165+
| Tool | Description | Required Parameters |
166+
| --------------------- | ---------------- | ------------------- |
167+
| `perses_list_plugins` | List all plugins | - |
142168

143169
### Variables
144170

145-
| Tool | Description | Required Parameters |
146-
| -------------------------------- | ----------------------------------------- | ------------------- |
147-
| `perses_list_global_variables` | List all global variables | - |
148-
| `perses_list_variables` | List all variables for a specific project | `project` |
149-
| `perses_create_project_variable` | Create a project-level variable | `name`, `project` |
171+
| Tool | Description | Required Parameters |
172+
| ------------------------------------- | ----------------------------------------- | --------------------- |
173+
| `perses_list_global_variables` | List all global variables | - |
174+
| `perses_get_global_variable_by_name` | Get a global variable by name | `variable` |
175+
| `perses_list_variables` | List all variables for a specific project | `project` |
176+
| `perses_get_project_variable_by_name` | Get a project variable by name | `project`, `variable` |
150177

151178
## License
152179

go.mod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/perses/mcp-server
33
go 1.24.1
44

55
require (
6-
github.com/mark3labs/mcp-go v0.31.0
7-
github.com/perses/perses v0.50.3
6+
github.com/mark3labs/mcp-go v0.32.0
7+
github.com/perses/perses v0.51.0
88
)
99

1010
require (
@@ -13,7 +13,7 @@ require (
1313
github.com/go-jose/go-jose/v4 v4.1.0 // indirect
1414
github.com/google/uuid v1.6.0 // indirect
1515
github.com/jpillora/backoff v1.0.0 // indirect
16-
github.com/labstack/echo/v4 v4.13.3 // indirect
16+
github.com/labstack/echo/v4 v4.13.4 // indirect
1717
github.com/labstack/gommon v0.4.2 // indirect
1818
github.com/mattn/go-colorable v0.1.14 // indirect
1919
github.com/mattn/go-isatty v0.0.20 // indirect
@@ -22,19 +22,19 @@ require (
2222
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
2323
github.com/prometheus/client_golang v1.22.0 // indirect
2424
github.com/prometheus/client_model v0.6.2 // indirect
25-
github.com/prometheus/common v0.63.0 // indirect
25+
github.com/prometheus/common v0.64.0 // indirect
2626
github.com/prometheus/procfs v0.16.1 // indirect
27-
github.com/spf13/cast v1.8.0 // indirect
27+
github.com/spf13/cast v1.9.2 // indirect
2828
github.com/valyala/bytebufferpool v1.0.0 // indirect
2929
github.com/valyala/fasttemplate v1.2.2 // indirect
3030
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
31-
github.com/zitadel/oidc/v3 v3.38.1 // indirect
31+
github.com/zitadel/oidc/v3 v3.39.0 // indirect
3232
github.com/zitadel/schema v1.3.1 // indirect
33-
golang.org/x/crypto v0.37.0 // indirect
34-
golang.org/x/net v0.39.0 // indirect
35-
golang.org/x/oauth2 v0.29.0 // indirect
36-
golang.org/x/sys v0.32.0 // indirect
37-
golang.org/x/text v0.24.0 // indirect
33+
golang.org/x/crypto v0.39.0 // indirect
34+
golang.org/x/net v0.41.0 // indirect
35+
golang.org/x/oauth2 v0.30.0 // indirect
36+
golang.org/x/sys v0.33.0 // indirect
37+
golang.org/x/text v0.26.0 // indirect
3838
google.golang.org/protobuf v1.36.6 // indirect
3939
gopkg.in/yaml.v2 v2.4.0 // indirect
4040
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
1818
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
1919
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
2020
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
21-
github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
22-
github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g=
21+
github.com/labstack/echo/v4 v4.13.4 h1:oTZZW+T3s9gAu5L8vmzihV7/lkXGZuITzTQkTEhcXEA=
22+
github.com/labstack/echo/v4 v4.13.4/go.mod h1:g63b33BZ5vZzcIUF8AtRH40DrTlXnx4UMC8rBdndmjQ=
2323
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
2424
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
25-
github.com/mark3labs/mcp-go v0.31.0 h1:4UxSV8aM770OPmTvaVe/b1rA2oZAjBMhGBfUgOGut+4=
26-
github.com/mark3labs/mcp-go v0.31.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4=
25+
github.com/mark3labs/mcp-go v0.32.0 h1:fgwmbfL2gbd67obg57OfV2Dnrhs1HtSdlY/i5fn7MU8=
26+
github.com/mark3labs/mcp-go v0.32.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4=
2727
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
2828
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
2929
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
@@ -36,22 +36,22 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+
3636
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
3737
github.com/nexucis/lamenv v0.5.2 h1:tK/u3XGhCq9qIoVNcXsK9LZb8fKopm0A5weqSRvHd7M=
3838
github.com/nexucis/lamenv v0.5.2/go.mod h1:HusJm6ltmmT7FMG8A750mOLuME6SHCsr2iFYxp5fFi0=
39-
github.com/perses/perses v0.50.3 h1:BHlU9qkCFCUSP4HP5p9GwophWcxm5Vnu6Fsrx8Fb/+w=
40-
github.com/perses/perses v0.50.3/go.mod h1:oqfHLOrXERvEqECShqXPjHXqVukQxcoaaTM6ySRF7hU=
39+
github.com/perses/perses v0.51.0 h1:lLssvsMjxFg2oP+vKX6pz2SFTfrUyso/A2/A/6oFens=
40+
github.com/perses/perses v0.51.0/go.mod h1:DrGiL+itTLl2mwEvNa0wGokELfZTsqOc3TEg+2B0uwY=
4141
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
4242
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4343
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
4444
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
4545
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
4646
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
47-
github.com/prometheus/common v0.63.0 h1:YR/EIY1o3mEFP/kZCD7iDMnLPlGyuU2Gb3HIcXnA98k=
48-
github.com/prometheus/common v0.63.0/go.mod h1:VVFF/fBIoToEnWRVkYoXEkq3R3paCoxG9PXP74SnV18=
47+
github.com/prometheus/common v0.64.0 h1:pdZeA+g617P7oGv1CzdTzyeShxAGrTBsolKNOLQPGO4=
48+
github.com/prometheus/common v0.64.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8=
4949
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
5050
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
51-
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
52-
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
53-
github.com/spf13/cast v1.8.0 h1:gEN9K4b8Xws4EX0+a0reLmhq8moKn7ntRlQYgjPeCDk=
54-
github.com/spf13/cast v1.8.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
51+
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
52+
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
53+
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
54+
github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
5555
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
5656
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
5757
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
@@ -60,21 +60,21 @@ github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQ
6060
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
6161
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
6262
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
63-
github.com/zitadel/oidc/v3 v3.38.1 h1:VTf1Bv/33UbSwJnIWbfEIdpUGYKfoHetuBNIqVTcjvA=
64-
github.com/zitadel/oidc/v3 v3.38.1/go.mod h1:muukzAasaWmn3vBwEVMglJfuTE0PKCvLJGombPwXIRw=
63+
github.com/zitadel/oidc/v3 v3.39.0 h1:WK3eNqmgshiYo1oEqONfXXbPbve+Qzgjl8KhKDFUvxc=
64+
github.com/zitadel/oidc/v3 v3.39.0/go.mod h1:JwdgdU/WxkmBtWuE8/pEjAbDTWXxJGqBix/gUoeEig4=
6565
github.com/zitadel/schema v1.3.1 h1:QT3kwiRIRXXLVAs6gCK/u044WmUVh6IlbLXUsn6yRQU=
6666
github.com/zitadel/schema v1.3.1/go.mod h1:071u7D2LQacy1HAN+YnMd/mx1qVE2isb0Mjeqg46xnU=
67-
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
68-
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
69-
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=
70-
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
71-
golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
72-
golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
67+
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
68+
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
69+
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
70+
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
71+
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
72+
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
7373
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
74-
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
75-
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
76-
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
77-
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
74+
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
75+
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
76+
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
77+
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
7878
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
7979
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
8080
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

main.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,39 @@ func main() {
5555

5656
//Project
5757
mcpServer.AddTool(tools.ListProjects(persesClient))
58-
mcpServer.AddTool(tools.CreateProject(persesClient))
58+
mcpServer.AddTool(tools.GetProjectByName(persesClient))
59+
// mcpServer.AddTool(tools.CreateProject(persesClient))
5960

6061
//Dashboard
6162
mcpServer.AddTool(tools.ListDashboards(persesClient))
63+
mcpServer.AddTool(tools.GetDashboardByName(persesClient))
6264

6365
//Datasource
6466
mcpServer.AddTool(tools.ListGlobalDatasources(persesClient))
65-
mcpServer.AddTool(tools.ListDatasources(persesClient))
67+
mcpServer.AddTool(tools.ListProjectDatasources(persesClient))
68+
mcpServer.AddTool(tools.GetGlobalDatasourceByName(persesClient))
69+
mcpServer.AddTool(tools.GetProjectDatasourceByName(persesClient))
70+
71+
// Roles and Role Bindings
72+
mcpServer.AddTool(tools.ListGlobalRoles(persesClient))
73+
mcpServer.AddTool(tools.GetGlobalRoleByName(persesClient))
74+
mcpServer.AddTool(tools.ListGlobalRoleBindings(persesClient))
75+
mcpServer.AddTool(tools.GetGlobalRoleBindingByName(persesClient))
76+
mcpServer.AddTool(tools.ListProjectRoles(persesClient))
77+
mcpServer.AddTool(tools.GetProjectRoleByName(persesClient))
78+
mcpServer.AddTool(tools.ListProjectRoleBindings(persesClient))
79+
mcpServer.AddTool(tools.GetProjectRoleBindingByName(persesClient))
80+
81+
// plugins
82+
mcpServer.AddTool(tools.ListPlugins(persesClient))
6683

6784
//Variable
6885
mcpServer.AddTool(tools.ListGlobalVariables(persesClient))
69-
mcpServer.AddTool(tools.ListVariables(persesClient))
70-
mcpServer.AddTool(tools.CreateProjectTextVariable(persesClient))
86+
mcpServer.AddTool(tools.GetGlobalVariableByName(persesClient))
87+
mcpServer.AddTool(tools.ListProjectVariables(persesClient))
88+
mcpServer.AddTool(tools.GetProjectVariableByName(persesClient))
89+
90+
// mcpServer.AddTool(tools.CreateProjectTextVariable(persesClient))
7191

7292
if err := server.ServeStdio(mcpServer); err != nil {
7393
slog.Error("Error starting server", "error", err)

pkg/tools/dashboards.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,33 @@ func ListDashboards(client apiClient.ClientInterface) (tool mcp.Tool, handler se
3333
return mcp.NewToolResultText(string(dashboardsJSON)), nil
3434
}
3535
}
36+
37+
func GetDashboardByName(client apiClient.ClientInterface) (tool mcp.Tool, handler server.ToolHandlerFunc) {
38+
return mcp.NewTool("perses_get_dashboard_by_name",
39+
mcp.WithDescription("Get a dashboard by name in a specific project"),
40+
mcp.WithString("project", mcp.Required(),
41+
mcp.Description("Project name")),
42+
mcp.WithString("name", mcp.Required(),
43+
mcp.Description("Dashboard name"))),
44+
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
45+
project, err := request.RequireString("project")
46+
if err != nil {
47+
return mcp.NewToolResultError(err.Error()), nil
48+
}
49+
name, err := request.RequireString("name")
50+
if err != nil {
51+
return mcp.NewToolResultError(err.Error()), nil
52+
}
53+
54+
dashboard, err := client.Dashboard(project).Get(name)
55+
if err != nil {
56+
return nil, fmt.Errorf("error retrieving dashboard '%s' in project '%s': %w", name, project, err)
57+
}
58+
59+
dashboardJSON, err := json.Marshal(dashboard)
60+
if err != nil {
61+
return nil, fmt.Errorf("error marshalling dashboard: %w", err)
62+
}
63+
return mcp.NewToolResultText(string(dashboardJSON)), nil
64+
}
65+
}

0 commit comments

Comments
 (0)