Skip to content

Commit c46c156

Browse files
Expose checks (#41)
* Expose checks --------- Co-authored-by: Farjaad Rawasia <[email protected]>
1 parent 32fb7e3 commit c46c156

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Added
2+
body: Add checks tool
3+
time: 2025-05-21T11:53:12.119491-04:00

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This MCP ([Model Context Protocol](https://modelcontextprotocol.io/introduction)
2727
Currently, the MCP server only uses read-only access to your OpsLevel account and can read data from the following resources:
2828

2929
- Actions
30+
- Checks
3031
- Components
3132
- Documentation (API & Tech Docs)
3233
- Domains

src/cmd/root.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ type serializedInfrastructureResource struct {
3939
ProviderType string
4040
}
4141

42+
type serializedLevel struct {
43+
Alias string
44+
Index int
45+
}
46+
47+
type serializedCheck struct {
48+
Id string
49+
Name string
50+
Owner string
51+
Description string
52+
Notes string
53+
Enabled bool
54+
Type string
55+
Level serializedLevel
56+
Category string
57+
}
58+
4259
// newToolResult creates a CallToolResult for the passed object handling any json marshaling errors
4360
func newToolResult(obj any, err error) (*mcp.CallToolResult, error) {
4461
if err != nil {
@@ -345,6 +362,41 @@ var rootCmd = &cobra.Command{
345362
return newToolResult(resp, err)
346363
})
347364

365+
// Register checks
366+
s.AddTool(
367+
mcp.NewTool(
368+
"checks",
369+
mcp.WithDescription("Get all the checks in the OpsLevel account. Checks provide a foundation for evaluating the maturity of software components, allowing for the definition and enforcement of criteria that ensure components are built and maintained according to best practices. Check priority is determined by level index, not level name—lower index means higher priority."),
370+
mcp.WithToolAnnotation(mcp.ToolAnnotation{
371+
Title: "Checks in OpsLevel",
372+
ReadOnlyHint: true,
373+
DestructiveHint: false,
374+
IdempotentHint: true,
375+
OpenWorldHint: true,
376+
}),
377+
),
378+
func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
379+
resp, err := client.ListChecks(nil)
380+
if err != nil {
381+
return nil, err
382+
}
383+
var checks []serializedCheck
384+
for _, node := range resp.Nodes {
385+
checks = append(checks, serializedCheck{
386+
Id: string(node.Id),
387+
Name: node.Name,
388+
Owner: node.Owner.Team.Alias,
389+
Description: node.Description,
390+
Notes: node.Notes,
391+
Type: string(node.Type),
392+
Level: serializedLevel{Alias: node.Level.Alias, Index: node.Level.Index},
393+
Category: node.Category.Name,
394+
Enabled: node.Enabled,
395+
})
396+
}
397+
return newToolResult(checks, nil)
398+
})
399+
348400
log.Info().Msg("Starting MCP server...")
349401
if err := server.ServeStdio(s); err != nil {
350402
if err == context.Canceled {

0 commit comments

Comments
 (0)