Fix audit MCP tool: add missing InputSchema for jq parameter#14442
Fix audit MCP tool: add missing InputSchema for jq parameter#14442
Conversation
The audit MCP tool had the jq filter implementation but was missing the InputSchema definition, causing MCP clients to reject the jq parameter as invalid. - Add GenerateOutputSchema for auditArgs - Add InputSchema to audit tool definition - Add comprehensive test coverage for audit jq filtering Fixes the issue where MCP clients would return: "MCP error -32602: invalid jq filter expression" Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Convert float64 comparisons to int64 to satisfy testifylint. The linter prefers integer comparisons when the values represent integer IDs or counts. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
pkg/cli/mcp_server.go
Outdated
| } | ||
|
|
||
| // Generate schema for audit tool | ||
| auditSchema, err := GenerateOutputSchema[auditArgs]() |
There was a problem hiding this comment.
It's an input schema. The function is confusingly named GenerateOutputSchema but it's actually generating a schema for the tool's input parameters (the auditArgs struct). This schema is then used as InputSchema in the MCP Tool definition (line 651), which tells MCP clients what parameters are available for the tool.
The naming confusion exists because the same function is also used to generate schemas for output data types (like LogsData, AuditData) in tests, but those aren't currently used in the actual tool definitions - only the input parameter schemas are.
There was a problem hiding this comment.
@copilot rename function to something less confusing
There was a problem hiding this comment.
Renamed to GenerateSchema in commit 55df751. The function is now clearly documented as being used for both input parameters (InputSchema) and output data schemas. Kept the old name as a deprecated wrapper for backward compatibility.
The function was confusingly named "GenerateOutputSchema" but was used for both input parameter schemas (InputSchema) and output data schemas. The new name "GenerateSchema" better reflects its generic purpose. - Renamed GenerateOutputSchema to GenerateSchema - Updated all usages in mcp_server.go (compile, logs, audit) - Kept GenerateOutputSchema as deprecated wrapper for compatibility - Updated documentation to clarify dual usage (input/output schemas) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
✅ Changeset Generator completed successfully! |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
There was a problem hiding this comment.
Pull request overview
This PR fixes the agenticworkflows-audit MCP tool rejecting the jq argument by adding the missing InputSchema for the audit tool, and clarifies schema helper naming by introducing GenerateSchema (with a deprecated GenerateOutputSchema wrapper).
Changes:
- Add
InputSchemageneration and wiring for theauditMCP tool sojqis accepted as a valid parameter. - Rename the schema helper to
GenerateSchemaand keepGenerateOutputSchemaas a compatibility wrapper. - Add new tests intended to cover jq filtering behavior for audit-shaped JSON.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/cli/mcp_server.go | Switch compile/logs to GenerateSchema and add audit tool InputSchema so jq is a declared MCP parameter. |
| pkg/cli/mcp_schema.go | Introduce GenerateSchema and keep GenerateOutputSchema as a deprecated wrapper; update documentation/comments. |
| pkg/cli/audit_jq_test.go | Adds tests for applying jq filters to representative audit JSON payloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func TestAuditJqFilter_BasicFiltering(t *testing.T) { | ||
| // Create sample audit JSON output | ||
| auditJSON := `{ | ||
| "overview": { | ||
| "run_id": 123456, | ||
| "workflow_name": "test-workflow", | ||
| "status": "completed", | ||
| "conclusion": "success" | ||
| }, | ||
| "metrics": { |
There was a problem hiding this comment.
This new test file doesn’t exercise the actual regression fixed by the PR (the audit MCP tool missing InputSchema for the jq parameter). It only tests ApplyJqFilter on sample JSON, which was already covered by jq_test.go. Add a test that verifies the audit tool’s MCP schema (via ListTools) includes a jq property / that a CallTool request with a jq argument is accepted (i.e., doesn’t fail schema validation with “invalid params”).
| // GenerateOutputSchema is deprecated. Use GenerateSchema instead. | ||
| // This function is kept for backward compatibility but will be removed in a future version. | ||
| func GenerateOutputSchema[T any]() (*jsonschema.Schema, error) { | ||
| return GenerateSchema[T]() |
There was a problem hiding this comment.
Go tooling (and this repo elsewhere) recognizes deprecations only when the doc comment starts with Deprecated:. Consider changing this to // Deprecated: Use GenerateSchema instead. so callers get proper deprecation signals in editors and staticcheck.
| @@ -19,21 +20,27 @@ import ( | |||
| // - PropertyOrder maintains deterministic field ordering (v0.4.0+) | |||
| // | |||
| // MCP Requirements: | |||
There was a problem hiding this comment.
The “Tool input/output schemas must be objects” note is misleading in this generic helper: GenerateSchema can produce array/primitive schemas (and the repo even tests array schemas). It’d be clearer to scope this requirement to MCP Tool.InputSchema (and Tool.OutputSchema, if/when used) rather than implying GenerateSchema always returns an object schema.
| // MCP Requirements: | |
| // MCP Tool Requirements (when using this helper for Tool.InputSchema/Tool.OutputSchema): |
| import ( | ||
| "encoding/json" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) |
There was a problem hiding this comment.
These tests call ApplyJqFilter(), which depends on an external jq binary. Unlike pkg/cli/jq_test.go, this file does not skip when jq isn’t available, so unit test runs in environments without jq will fail. Add an exec.LookPath("jq") guard (or a shared helper) to t.Skip at the start of these tests when jq is missing.
|
PRs checked: #14435 Standardize error wrapping in compiler to preserve error chains; #14425 Fix plugin installation format from marketplace URL to GitHub repository path
|
Agent Container Tool Check
Result: 10/12 tools verified ✅, 2/12 tools present but malfunctioning Critical Issue DetectedJava and .NET binaries exist as valid ELF executables at:
However, executing these commands returns:
This indicates a system-level process execution issue, possibly:
Impact: While 10/12 critical development tools work correctly, Java and .NET workflows will fail. This needs investigation before releasing workflows that depend on these runtimes.
|
Smoke Test Results
Overall: PARTIAL PASS (Serena MCP connection issue) @pelikhan
|
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
Fix Audit Command jq Support ✅
Root Cause:
The audit MCP tool had the
JqFilterfield defined in the args struct and the jq filtering logic fully implemented, but was missing the InputSchema definition. This caused MCP clients to reject thejqparameter as invalid because it wasn't declared in the tool's schema.Changes Made:
1.
pkg/cli/mcp_server.go:GenerateSchema[auditArgs]()InputSchema: auditSchemato the audit tool definitionGenerateSchema(renamed fromGenerateOutputSchema)2.
pkg/cli/mcp_schema.go:GenerateOutputSchematoGenerateSchemafor clarityGenerateOutputSchemaas deprecated wrapper for backward compatibility3.
pkg/cli/audit_jq_test.go(new file):.overview,.metrics,.jobs)Naming Clarification:
The original function name
GenerateOutputSchemawas misleading because:GenerateSchemabetter reflects its generic, dual-purpose natureTool Comparison:
Validation Results:
Example Usage (Now Works):
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Changeset