Skip to content

mcp: fix Gemini register_version schema + optional types#562

Merged
coleam00 merged 3 commits intocoleam00:mainfrom
leoric-crown:chore/mcp-gemini-register-version-schema
Sep 6, 2025
Merged

mcp: fix Gemini register_version schema + optional types#562
coleam00 merged 3 commits intocoleam00:mainfrom
leoric-crown:chore/mcp-gemini-register-version-schema

Conversation

@leoric-crown
Copy link
Copy Markdown

@leoric-crown leoric-crown commented Sep 2, 2025

This PR fixes the following failed MCP tool load in Gemini CLI:

❯ gemini
Skipping tool 'create_version' from MCP server 'archon' because it has missing types in its parameter schema.
Please file an issue with the owner of the MCP server.

Summary of changes:

  • Constrain create_version content to JSON-serializable dict or list of dicts to satisfy Gemini/MCP schema expectations (avoid untyped Any).
  • Use str or None for optional source_domain params in RAG tools.

Rationale:
These type adjustments align tool schemas with MCP expectations so Gemini recognizes the register version tools reliably.

Notes: No functional behavior changed beyond type annotations; low risk.

Summary by CodeRabbit

  • Refactor

    • Tightened type for document version content to require JSON-serializable objects/arrays.
    • Made the “source domain” parameter explicitly optional in knowledge search and code example tools for consistency.
  • Chores

    • Improved type safety and consistency; no runtime or API behavior changes.

…rain to JSON-serializable dict | list[dict] for create_version\n- Use for optional args in RAG tools\n- Add AGENTS.md with repo guidelines
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 2, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Type annotations were tightened for public tool functions. The documents version tool now restricts content to JSON-serializable dict[str, Any] or list[dict[str, Any]]. In the RAG module, source_domain is explicitly optional (str | None). No control flow, HTTP behavior, or return types were changed.

Changes

Cohort / File(s) Summary
Documents version tool typing
python/src/mcp_server/features/documents/version_tools.py
Narrowed create_version content parameter from Any to `dict[str, Any]
RAG tools optional domain typing
python/src/mcp_server/modules/rag_module.py
Updated perform_rag_query and search_code_examples signatures to use `str

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

I twitch my whiskers at types made clean,
Dicts in neat rows, lists crisp and lean.
RAG now knows when domains are none—
Optional paths, yet queries still run.
In burrows of code I softly cheer, hop-hop, my dear! 🐇


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d573528 and 5686714.

📒 Files selected for processing (1)
  • python/src/mcp_server/features/documents/version_tools.py (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
python/src/mcp_server/features/documents/version_tools.py (1)

31-33: Good fix: constraining content removes bare Any from MCP schema; consider two small schema-oriented tweaks

  • Consider typing field_name as a Literal to emit an enum in the tool schema, which helps Gemini/clients validate inputs earlier:

    from typing import Literal
    # ...
    async def create_version(
        ctx: Context,
        project_id: str,
        field_name: Literal["docs", "features", "data", "prd"],
        content: dict[str, Any] | list[dict[str, Any]],
        change_summary: str | None = None,
        document_id: str | None = None,
        created_by: str = "system",
    ) -> str:
        ...
  • For consistency with Python 3.12 style used elsewhere in the PR, prefer str | None over Optional[str] for change_summary/document_id here (and the other tool functions in this file).

python/src/mcp_server/modules/rag_module.py (1)

81-81: Signature change to source_domain: str | None looks right; one minor semantics nit

Current check uses if source_domain: which ignores empty strings. If empty string should be treated as “provided but invalid,” switch to if source_domain is not None: and validate non-empty separately; otherwise, keep as-is.

Also applies to: 138-138

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 230f825 and d573528.

📒 Files selected for processing (2)
  • python/src/mcp_server/features/documents/version_tools.py (1 hunks)
  • python/src/mcp_server/modules/rag_module.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
python/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

python/**/*.py: Target Python 3.12 with a 120-character line length
Use Ruff for linting and Mypy for type checking before commit

Files:

  • python/src/mcp_server/features/documents/version_tools.py
  • python/src/mcp_server/modules/rag_module.py
{python/**/*.py,archon-ui-main/src/**/*.{ts,tsx,js,jsx}}

📄 CodeRabbit inference engine (CLAUDE.md)

{python/**/*.py,archon-ui-main/src/**/*.{ts,tsx,js,jsx}}: Remove dead code immediately; do not keep legacy/unused functions
Avoid comments that reference change history (e.g., LEGACY, CHANGED, REMOVED); keep comments focused on current functionality

Files:

  • python/src/mcp_server/features/documents/version_tools.py
  • python/src/mcp_server/modules/rag_module.py

@coleam00
Copy link
Copy Markdown
Owner

coleam00 commented Sep 6, 2025

Thank you for this @leoric-crown!

@coleam00 coleam00 merged commit 52ee5e2 into coleam00:main Sep 6, 2025
1 check was pending
leonj1 pushed a commit to leonj1/Archon that referenced this pull request Oct 13, 2025
* mcp: fix Gemini register_version schema and optional types\n\n- Constrain  to JSON-serializable dict | list[dict] for create_version\n- Use  for optional args in RAG tools\n- Add AGENTS.md with repo guidelines

* mcp: remove unintended AGENTS.md from PR

---------

Co-authored-by: Cole Medin <cole@dynamous.ai>
POWERFULMOVES added a commit to POWERFULMOVES/PMOVES-Archon that referenced this pull request Feb 12, 2026
)

* fix(cataclysm): Restore CATACLYSM_STUDIOS_INC business documents

Restores 189 files that were deleted in commit 4490fcde (tier architecture
implementation). These documents contain important business, legal, and
project planning materials:

ABOUT/:
- MVP & Community Engagement, Content Strategy
- Research SIM/TCM documentation, FAQs
- YouTube Channel Content Strategy

Charters/:
- Fordham Hill Board/Business/Residents Decks (PowerPoint)
- Infra & Cloud Guild Charters (Word)
- RPE Topic Synthesis Appendix

Constitutions/:
- Cataclysm DAO Constitution v0.1

Food Cooperative & Group Buying System:
- Tokenomics & Smart Contract Design (v1.0, v2.0)
- System design documents
- Integration of hybrid manufacturing & tokenized co-ops

Projections/:
- 5-Year Business Projections (AI + Tokenomics)
- Community Wealth Building models
- Containerized Micro Business Model
- Docker-Style Scalable Business Container

PMOVES-PROVISIONS/:
- docker-stacks/jellyfin-ai/api-gateway (Node.js)

Data & Charts:
- AI tokenomics business projections (CSV)
- Breakeven analysis, business model summaries

These are critical business documents that should not have been deleted.
Restoring from commit before 4490fcde.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(submodules): Register untracked submodules and fix paths

Fixed submodule registrations:
- Added PMOVES-AgentGym (was missing from .gitmodules)
- Added PMOVES-E2B-Danger-Room (was missing from .gitmodules)
- Fixed pmoves-surf path → PMOVES-surf (case mismatch)
- Removed PMOVES-E2B-Danger-Room-Deskdesktop (typo duplicate)
- Registered 11 previously untracked submodules in git index

Submodules now properly tracked:
- PMOVES-AgentGym
- PMOVES-Archon
- PMOVES-Deep-Serch
- PMOVES-E2B-Danger-Room
- PMOVES-E2B-Danger-Room-Desktop
- PMOVES-HiRAG
- PMOVES-Remote-View
- PMOVES-Tailscale
- PMOVES-surf
- PMOVES.YT
- Pmoves-Jellyfin-AI-Media-Stack

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(agent-zero): Add instruments, knowledge bases and sync scripts

Added Agent Zero instruments:
- custom/ directory for custom tools
- default/yt_download/ - YouTube download instrument (Python + shell)
- .gitkeep files for empty directories

Added Agent Zero knowledge bases:
- custom/ and default/ directories for knowledge storage
- main/about/ - GitHub readme and installation docs
- solutions/ for solution knowledge

Added scripts:
- sync-upstream-forks.sh - Sync forked submodules with upstream

Documentation:
- docs/submodules-audit-p4-p5-summary.md - P4-P5 audit summary

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore(submodules): Update submodule SHAs and fix .gitmodules

- Add PMOVES-AgentGym submodule registration
- Add PMOVES-E2B-Danger-Room submodule registration
- Fix pmoves-surf -> PMOVES-surf path case
- Remove typo submodule PMOVES-E2B-Danger-Room-Deskdesktop
- Update all submodule SHAs after security hardening

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: Comprehensive security documentation refresh (2026-01-29)

## Overview
Update all core documentation to reflect Phase 2 completion of security
hardening, including dual-tiered security architecture, USER directives,
and production deployment patterns.

## Updated Files (5)
- PMOVES.AI-Edition-Hardened-Full.md: Added dual-tiered security section
- architecture/network-tier-segmentation.md: Cross-references to 6-tier env
- PMOVES_Git_Organization.md: Updated Phase 3 with week-by-week plan
- Security-Hardening-Roadmap.md: Marked Phase 1-2 complete (95/100 score)
- PMOVES.AI Services and Integrations.md: Restructured as defense-in-depth

## New Files (10)
- architecture/6-tier-environment-architecture.md: Secret tier architecture
- production/Tailscale-Integration.md: VPN configuration guide
- production/GHCR-Namespace-Publishing.md: Image publishing patterns
- external-references-summary-2026-01-29.md: Latest GitHub/Docker findings
- Security-Hardening-Summary-2025-01-29.md: Consolidated security summary
- templates/: Standard documentation templates
- submodules-upstream-audit.md: Fork audit results

## Key Highlights
- 5-tier network segmentation (physical isolation)
- 6-tier environment architecture (logical secret isolation)
- USER directive 100% adoption across 35/35 custom services
- GHCR lowercase namespace normalization
- Tailscale VPN for production access
- TensorZero as "secrets fence" for LLM API keys

## Security Score
- Current: 95/100 (Phase 1-2 complete)
- Target: 98/100 (Phase 3 Q1 2026)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(events): Implement event-driven coordination bus for Agent Zero

Implements an event bus for agent coordination based on PMOVES-ToKenism-Multi
patterns, enabling pub/sub messaging with NATS and schema validation.

## Changes

- **Event Bus** (`bus.py`): Async NATS-backed event bus with retry logic
  - Event envelope with id, timestamp, type, source, data, metadata
  - publish(), subscribe(), request() methods
  - Singleton get_event_bus() function
  - Metrics tracking (published, processed, failed)
- **Event Subjects** (`subjects.py`): Standard event subject constants
  - Agent lifecycle: AGENT_STARTED, AGENT_STOPPED, AGENT_ERROR
  - Task events: TASK_CREATED, TASK_ASSIGNED, TASK_COMPLETED, TASK_FAILED
  - Tool events: TOOL_STARTED, TOOL_COMPLETED, TOOL_FAILED
  - A2A events: A2A_TASK_SUBMITTED, A2A_TASK_RECEIVED, A2A_ARTIFACT_READY
  - Wildcard subjects: ALL_PMOVES_EVENTS, ALL_AGENT_EVENTS, etc.
- **Schema Validator** (`schema.py`): JSON schema validation for events
  - 10 predefined schemas for common event types
  - Schema registry with load from directory support
- **Test Suite** (`test_bus.py`): 6 comprehensive test cases

## Features

- NATS JetStream support for reliable delivery
- Wildcard subscriptions (`pmoves.>` for all events)
- Schema validation with graceful fallback
- Request-reply pattern support
- Connection retry with exponential backoff

## Integration

- Subject pattern: `pmoves.{service}.{event}.v1`
- Compatible with existing NATS infrastructure
- Metrics available via get_metrics()

## References

- PMOVES-ToKenism-Multi event bus architecture
- PMOVES.AI NATS subject catalog
- PMOVES.AI AGENTS implementation roadmap

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(events): Address race conditions and memory leaks from PR review

Critical Fixes:
1. Event ID collision - Changed from time.time() to uuid.uuid4() for
   collision-free unique IDs (tested with 10,000 events, zero collisions)

2. Thread-safe metrics - Added _metrics_lock (asyncio.Lock) to protect
   metrics updates from race conditions (tested with 100 concurrent tasks)

3. Memory leak in subscriptions - Implemented weakref-based handler
   tracking with automatic cleanup when handlers are garbage collected

4. Unbounded subscription growth - Added unsubscribe() method and
   subscription IDs for proper resource management

5. JetStream acknowledgment - Added proper ack/nak handling for JetStream
   messages with error recovery

Important Fixes:
1. Connection failure handling - Added reconnection callbacks
   (_on_disconnect, _on_reconnect, _on_error, _on_close) with infinite
   reconnect attempts

2. Improved metrics API - Made get_metrics() async with lock protection,
   added get_metrics_sync() for non-blocking reads

3. JetStream support - Added use_jetstream parameter and js context
   initialization

4. Better error recovery - Messages are nacked on handler errors for
   automatic retry in JetStream

Testing:
- Added test_critical_fixes.py with 8 unit tests (7 passing)
- Added test_thread_safety.py with 9 integration tests (requires NATS)
- Verified: 10,000 unique event IDs with UUID v4
- Verified: Thread-safe metrics with 100 concurrent tasks
- Verified: Subscription tracking structures

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Codex Agent <codex-agent@example.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants