41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package tools
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"code.nochebuena.dev/einherjar/mcp/internal/index"
|
||
|
|
"github.com/modelcontextprotocol/go-sdk/mcp"
|
||
|
|
)
|
||
|
|
|
||
|
|
type listADRsInput struct {
|
||
|
|
Module string `json:"module,omitempty" jsonschema:"restrict to one module by name"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type listADRsOutput struct {
|
||
|
|
ADRs []adrSummary `json:"adrs"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type adrSummary struct {
|
||
|
|
Module string `json:"module"`
|
||
|
|
ID string `json:"id"`
|
||
|
|
Title string `json:"title"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func registerListADRs(s *mcp.Server, idx *index.Index) {
|
||
|
|
mcp.AddTool(s, &mcp.Tool{
|
||
|
|
Name: "list_adrs",
|
||
|
|
Description: "List architectural decision records across Einherjar. Optionally restrict to one module. Use to discover the rationale behind framework design choices.",
|
||
|
|
}, func(ctx context.Context, req *mcp.CallToolRequest, args listADRsInput) (*mcp.CallToolResult, listADRsOutput, error) {
|
||
|
|
out := listADRsOutput{ADRs: []adrSummary{}}
|
||
|
|
for _, m := range idx.Modules {
|
||
|
|
if args.Module != "" && m.Name != args.Module {
|
||
|
|
continue
|
||
|
|
}
|
||
|
|
for _, a := range m.ADRs {
|
||
|
|
out.ADRs = append(out.ADRs, adrSummary{Module: m.Name, ID: a.ID, Title: a.Title})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return jsonText(out), out, nil
|
||
|
|
})
|
||
|
|
}
|