feat(discovery): add format parameter for structured JSON output#256
Merged
unifiedh merged 1 commit intoConway-Research:mainfrom Mar 3, 2026
Merged
Conversation
discover_agents now accepts an optional format parameter. When set to "json", it returns a JSON array of objects with agentId, owner, agentURI, name, and description fields — enabling agents to programmatically process discovery results without parsing text. Default output remains unchanged (human-readable text). Both discoverAgents and searchAgents results benefit via the shared formatter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
discover_agentsreturns human-readable text output only. Agents that need to programmatically process discovery results — building directories, filtering by capability, persisting structured records — must parse unstructured text back into individual fields. The structured data exists upstream in theDiscoveredAgenttype but is discarded during formatting.Solution
Added an optional
formatparameter to thediscover_agentstool definition.File:
src/agent/tools.tsChange 1: Parameter schema (line ~1428)
Added
formatproperty toparameters.properties:Change 2: JSON output branch (line ~1447)
Added conditional JSON serialization before the existing text formatter:
Design Decisions
DiscoveredAgentgains internal fieldsnullfor missing fields — clean JSON rather than fallback values like"unnamed".toLowerCase()handles"json","JSON","Json"discoverAgentsandsearchAgentsshare the same formatterVerification
pnpm build— zero errorsnpx vitest run src/__tests__/tools-security.test.ts— 68/68 passednpx vitest run src/__tests__/policy-engine.test.ts— 26/26 passedImpact