mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-09 09:11:00 +08:00
Three bugs prevented the update notice from appearing: - checkForUpdate goroutine launched after blocking sessionOnce.Do, so it never ran before tool calls arrived - 4KB body limit truncated the ~15KB GitHub API response - Notice was a JSON map key with no guaranteed ordering Fixes: - Move go checkForUpdate() before sessionOnce.Do in all handlers - Increase body read limit to 64KB - Prepend notice as separate MCP TextContent block (appears first) - Link to GitHub releases page instead of go install command
44 lines
998 B
Go
44 lines
998 B
Go
package tools
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/DeusData/codebase-memory-mcp/internal/cypher"
|
|
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
)
|
|
|
|
func (s *Server) handleQueryGraph(_ context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
|
args, err := parseArgs(req)
|
|
if err != nil {
|
|
return errResult(err.Error()), nil
|
|
}
|
|
|
|
query := getStringArg(args, "query")
|
|
if query == "" {
|
|
return errResult("missing required 'query' parameter"), nil
|
|
}
|
|
|
|
st, err := s.resolveStore(getStringArg(args, "project"))
|
|
if err != nil {
|
|
return errResult(fmt.Sprintf("resolve store: %v", err)), nil
|
|
}
|
|
|
|
exec := &cypher.Executor{Store: st}
|
|
result, err := exec.Execute(query)
|
|
if err != nil {
|
|
return errResult(fmt.Sprintf("query error: %v", err)), nil
|
|
}
|
|
|
|
responseData := map[string]any{
|
|
"columns": result.Columns,
|
|
"rows": result.Rows,
|
|
"total": len(result.Rows),
|
|
}
|
|
s.addIndexStatus(responseData)
|
|
|
|
res := jsonResult(responseData)
|
|
s.addUpdateNotice(res)
|
|
return res, nil
|
|
}
|