Skip to content

feat: add index.mcp.json - MCP-readable template index with descriptions#932

Open
lin-bot23 wants to merge 22 commits into
Comfy-Org:mainfrom
lin-bot23:feat/index-mcp-json
Open

feat: add index.mcp.json - MCP-readable template index with descriptions#932
lin-bot23 wants to merge 22 commits into
Comfy-Org:mainfrom
lin-bot23:feat/index-mcp-json

Conversation

@lin-bot23

Copy link
Copy Markdown
Contributor

Summary

Adds templates/index.mcp.json — a machine-readable index of all 526 workflow templates enriched with descriptions and input/output metadata for MCP (Model Context Protocol) integration.

This is generated from the existing templates/templates-context.json skeleton, with AI-friendly descriptions and refined IO types added for every template.

Changes

  • New file: templates/index.mcp.json (526 templates, each with name, title, category, task, description, io.inputs, io.outputs)
  • Removed: templates/templates-context.json (replaced by index.mcp.json)

What each template entry contains

{
  "name": "template_xyz",
  "title": "Template Title",
  "category": "image",
  "task": "text-to-image",
  "model": "...",
  "tags": ["cloud", "flux"],
  "description": "AI-friendly English description of what the workflow does...",
  "io": {
    "inputs": [{"type": "image|text|video", "count": 1, "purpose": "..."}],
    "outputs": [{"type": "image|video|audio|model", "count": 1, "purpose": "..."}]
  },
  "freshness": "...",
  "usage": 42,
  "recommend": 60
}

Generation approach

  • 361 templates: Processed via AI-assisted batch generation (271 API + 90 Cloud) with descriptions tailored to each template's specific model and capabilities
  • 165 templates: Generated programmatically with model-specific knowledge using task/type inference
  • Suffix: Cloud templates end with "This workflow runs on Comfy Cloud and executes quickly." API templates end with "This workflow calls a third-party API."

Verification

  • All 526 templates have non-empty descriptions ✅
  • All 526 templates have proper io.inputs and io.outputs ✅
  • No grammar issues "a [vowel]" patterns ✅

…ons and IO metadata

Generates AI-friendly descriptions for all 526 templates (271 API + 255 Cloud),
with refined input/output type specifications for MCP tool integration.

- Adds templates/index.mcp.json replacing templates/templates-context.json
- Each template now has: description, io.inputs, io.outputs
- Cloud templates: end with 'This workflow runs on Comfy Cloud and executes quickly.'
- API templates: end with 'This workflow calls a third-party API.'
- 361 templates via AI-assisted batch generation
- 165 templates via programmatic generation with model-specific knowledge
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🔤 Spellcheck Results

Check Status
templates/index.json (titles & descriptions) ✅ No issues found
Workflow JSON notes (MarkdownNote / Note nodes) ✅ No issues found

All spellchecks passed! 🎉

lin-bot23 added 6 commits June 9, 2026 12:14
…ex.json

Aligns the MCP index structure with the original index.json:
- 9 groups: Use Cases, Image, Video, Audio, 3D Model, LLM, Utility, Getting Started, Node Basics
- Each group has moduleName, category, icon, title, type
- Templates nested within their group
Automatically detects new/removed templates from index.json and updates
index.mcp.json accordingly. Existing descriptions are preserved.
@lin-bot23 lin-bot23 force-pushed the feat/index-mcp-json branch from fbaf53a to 20b0935 Compare June 11, 2026 11:41
- New models_capabilities.json mapping ~47 major models to
  capability tags (e.g. text-to-image, t2v, lip-sync, controlnet)
- sync-mcp-index.py: inject capabilities into index.mcp.json
  via resolve_model() lookup when syncing
- index.mcp.json: 358/526 templates now have capabilities array
@CLAassistant

CLAassistant commented Jun 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A new Python script scripts/sync-mcp-index.py is added to generate templates/index.mcp.json from templates/index.json, enriched by a new scripts/models_capabilities.json model registry. The index.mcp bundle identifier is registered in bundles.json.

Changes

MCP Index Sync Tooling

Layer / File(s) Summary
Static model capabilities registry
scripts/models_capabilities.json
Adds a comprehensive JSON mapping covering 100+ model identifiers (Flux, Wan, Kling, Gemini/GPT, Qwen, Ideogram, Recraft, Hunyuan3D, Stable Diffusion, upscaling/audio/utility families) to summary strings and capabilities arrays.
Script initialization and model resolution
scripts/sync-mcp-index.py (lines 1–202)
Establishes file path constants, loads MODELS_CAP from the capabilities JSON with an empty-dict fallback, defines MODEL_DESC_MAP, and implements resolve_model, extract_model_name, and get_model_desc for canonical name and description lookup.
Workflow scanning and task/IO inference
scripts/sync-mcp-index.py (lines 204–393)
Implements scan_workflow_nodes to collect node types from template JSON files, infer_task/infer_task_type for name/pattern-based task labeling, infer_io to generate typed input/output schemas across all modalities, resolve_mcp_category to map group titles to MCP categories, and auto_description for placeholder text on new entries. One inference to infer-ence them all!
Core sync logic and CLI entrypoint
scripts/sync-mcp-index.py (lines 395–556)
sync() loads both index files, rebuilds the grouped MCP structure—preserving description/io on existing entries, constructing full metadata for new ones, and dropping removed entries. main() adds --check dry-run support.
Bundle registration and schema validation
bundles.json, scripts/validate_templates.py
bundles.json registers index.mcp in the media-other array, and validate_templates.py excludes index.mcp.json from schema validation to prevent generated files from triggering validation checks.
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

@lin-bot23 lin-bot23 force-pushed the feat/index-mcp-json branch from bff1b13 to cd665b1 Compare June 16, 2026 16:16
- Expanded model coverage with detailed summaries and capabilities
- Covers image generation, video generation, image enhancement,
  and video enhancement models
- All entries include structured summary and capabilities arrays
sync_bundles.py requires all JSON files under templates/ to be
assigned in bundles.json. These are index data files, not workflow
templates — added to media-other bundle per validation requirement.
@lin-bot23 lin-bot23 force-pushed the feat/index-mcp-json branch from cd665b1 to c10c2e4 Compare June 16, 2026 16:17

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bundles.json`:
- Line 493: The bundle identifier "templates-context" in bundles.json at line
493 does not resolve to any existing template/manifest entry, causing the
validation pipeline to fail. Either replace "templates-context" with a correct
existing bundle identifier that matches an actual template/manifest entry, or
remove the "templates-context" entry entirely from the bundles.json file until
the corresponding manifest side is added and the identifier becomes valid.

In `@scripts/sync-mcp-index.py`:
- Line 21: The script has two Ruff linter violations that need to be fixed. On
line 21, the comma-separated import statement violates the E-rule for import
style; split the single import line with multiple modules (json, os, sys, time)
into separate import statements with one module per line. On line 307, there is
an unused local variable named name_l that violates the F-rule; remove this
unused variable assignment to eliminate the violation.
- Around line 33-37: The try-except block around the MODELS_CAP file loading is
catching all exceptions indiscriminately and defaulting to an empty dictionary,
which hides actual errors like malformed JSON or configuration issues. Replace
the broad `except Exception:` clause with a specific `except FileNotFoundError:`
to only catch and handle the case where the MODELS_CAP_FILE is missing, allowing
json.JSONDecodeError and other parsing errors to propagate and surface the
actual root cause during execution.
- Around line 386-387: The operator precedence in the model_info assignment at
line 386-387 is incorrect. The current expression is parsed as
`(MODELS_CAP.get(model) or MODELS_CAP.get(models[0])) if models else None`,
which means the entire assignment evaluates to None whenever models is empty,
losing any valid model_info from MODELS_CAP.get(model). Fix this by adding
parentheses to explicitly group the fallback logic: wrap the conditional
`MODELS_CAP.get(models[0]) if models else None` in parentheses so it becomes the
second operand of the or operator. This ensures that if models is empty, the
expression still returns the result from MODELS_CAP.get(model) if it exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5621dc83-0284-49f0-9e62-5657076d0af2

📥 Commits

Reviewing files that changed from the base of the PR and between 5d8a645 and c10c2e4.

📒 Files selected for processing (4)
  • bundles.json
  • scripts/models_capabilities.json
  • scripts/sync-mcp-index.py
  • templates/index.mcp.json

Comment thread bundles.json Outdated
Comment thread scripts/sync-mcp-index.py Outdated
Comment thread scripts/sync-mcp-index.py
Comment thread scripts/sync-mcp-index.py Outdated
- Remove 89 models not referenced in index.mcp.json
- Add 69 models that are in index.mcp but were missing
- Include pricing info (credits, time, quality rating, category) for 53 models
- Fix \x08 backspace character in 'Depth Anything v2' model name
- Total: 122 models = 120 unique models from index.mcp

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/models_capabilities.json (1)

262-277: ⚠️ Potential issue | 🟠 Major

Eliminate case-variant model key collisions and add missing pricing category.

Two fixable issues in the models registry:

  1. Case-variant duplicate keys (Kling O1/Kling o1, Kling O3/Kling o3): resolve_model() performs case-insensitive substring matching as a fallback when templates lack explicit models. If two keys collide on case-insensitive lookup, the tie-breaker is non-deterministic. Currently templates use correct casing and avoid collision, but this is a latent trap—same name, different hat is metadata mischief waiting to happen. Consolidate to a single canonical casing (suggest uppercase O1/O3 to match current template references).

  2. SeedVR2 missing pricing.category: This is the only model in the registry without a category field. All other 52 models include it. Add "category" to SeedVR2's pricing object to match schema and align with PR objectives.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/models_capabilities.json` around lines 262 - 277, In the models
registry, address two issues: first, consolidate case-variant model keys that
cause non-deterministic matching in resolve_model() by finding all occurrences
of Kling O1/Kling o1 and Kling O3/Kling o3, then retain only the uppercase
canonical versions (Kling O1 and Kling O3) and remove the lowercase variants;
second, locate the SeedVR2 model entry in the registry and add the missing
"category" field to its pricing object to match the schema used by all other 52
models in the registry (specify an appropriate category value consistent with
similar models).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/models_capabilities.json`:
- Around line 660-664: Add a missing `category` field to the SeedVR2.pricing
object in scripts/models_capabilities.json to maintain schema consistency with
the other 52 models that include pricing. The pricing object for SeedVR2
currently contains credits, estimated_seconds, and quality_rating fields, but
lacks the category field that all other pricing entries include (such as
"quality" or "legacy"). Add this field to the pricing object to match the
expected pricing schema.

---

Outside diff comments:
In `@scripts/models_capabilities.json`:
- Around line 262-277: In the models registry, address two issues: first,
consolidate case-variant model keys that cause non-deterministic matching in
resolve_model() by finding all occurrences of Kling O1/Kling o1 and Kling
O3/Kling o3, then retain only the uppercase canonical versions (Kling O1 and
Kling O3) and remove the lowercase variants; second, locate the SeedVR2 model
entry in the registry and add the missing "category" field to its pricing object
to match the schema used by all other 52 models in the registry (specify an
appropriate category value consistent with similar models).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9988daba-2b43-4995-b7a2-20eaabe1d5b4

📥 Commits

Reviewing files that changed from the base of the PR and between c10c2e4 and fc70c7a.

📒 Files selected for processing (2)
  • scripts/models_capabilities.json
  • templates/index.mcp.json

Comment thread scripts/models_capabilities.json
templates-context.json was an untracked file artifact, not tracked in
git. Removed the bundle assignment and deleted the file to fix CI.
…ls_capabilities

- Split comma-separated import into individual lines (Ruff E-rule)
- Remove unused name_l variable at line 307 (Ruff F-rule)
- Refine MODELS_CAP loading: only catch FileNotFoundError, fail on malformed JSON
- Fix operator precedence in model_info lookup (capabilities dropping bug)
- Add missing category field to SeedVR2.pricing
validate_templates.py scans all index*.json files against
index.schema.json, but index.mcp.json has a different structure
(MCP-specific format). Excluding it from the scan fixes the
schema validation failure in CI.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
scripts/sync-mcp-index.py (1)

21-24: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove unused imports to satisfy Ruff F-rules.

Line 22 (os) and Line 24 (time) are imported but unused; tiny lint, tidy win — less clutter, less flutter.

As per coding guidelines, **/*.py: “Use Ruff linter with line-length 100 and target Python 3.12, selecting rules E and F for Python files.”

💡 Suggested fix
 import json
-import os
 import sys
-import time
 from pathlib import Path
 from typing import Any, Optional
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/sync-mcp-index.py` around lines 21 - 24, Remove the unused imports os
and time from the import section at the top of the file. Keep only the imports
that are actually used in the script (json and sys). This will satisfy Ruff's
F-rules which flag unused imports and variables.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@scripts/sync-mcp-index.py`:
- Around line 21-24: Remove the unused imports os and time from the import
section at the top of the file. Keep only the imports that are actually used in
the script (json and sys). This will satisfy Ruff's F-rules which flag unused
imports and variables.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ffe81575-a93f-4ca8-97da-2c0868dfb128

📥 Commits

Reviewing files that changed from the base of the PR and between fc70c7a and c201b41.

📒 Files selected for processing (3)
  • bundles.json
  • scripts/models_capabilities.json
  • scripts/sync-mcp-index.py

lin-bot23 and others added 2 commits June 17, 2026 01:01
All 122 models had stale capabilities tags (e.g. text-to-image,
photorealism, controlnet) that were unused and derived from
a previous data extraction source. Cleared them.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/models_capabilities.json (1)

4-686: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Capabilities registry is effectively disabled by empty arrays.

Line 4 and the same pattern across this file set capabilities to [] for model entries, but scripts/sync-mcp-index.py only propagates capabilities when the array is non-empty. Net effect: generated MCP metadata cannot be refreshed from this registry for those models, and new entries may miss capability tags. Empty tags, empty brag—metadata takes the lag.

Please either (a) repopulate non-empty capability arrays for models meant to drive MCP output, or (b) update sync logic to intentionally handle this “no capabilities” mode without silently dropping enrichment.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/models_capabilities.json` around lines 4 - 686, The capabilities
registry in models_capabilities.json has empty arrays for all model entries,
which prevents the sync-mcp-index.py script from propagating capability metadata
since it only processes non-empty capability arrays. To fix this, either
populate the empty capabilities arrays with actual capability tags for each
model that should be reflected in MCP output (such as "text-to-image",
"video-generation", "editing", etc.), or update the capability propagation logic
in scripts/sync-mcp-index.py to explicitly handle and preserve models with empty
capability arrays instead of silently skipping them during metadata enrichment.
Choose the approach based on whether these models should have defined
capabilities or if empty capabilities is an intentional state that should still
be reflected in the generated MCP metadata.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/validate_templates.py`:
- Around line 613-617: The exclusion of index.mcp.json from index-schema
validation at line 616 leaves that file completely unchecked despite it being
shipped in bundles.json, creating a release gap. Keep the exclusion from the
schema validation but add a dedicated validation check in a separate branch that
validates templates/index.mcp.json with minimum checks: verify the file exists,
verify the JSON parses successfully, and verify the top-level structure matches
expected format. This ensures index.mcp.json receives baseline validation
coverage even though it is excluded from the schema validation loop.

---

Outside diff comments:
In `@scripts/models_capabilities.json`:
- Around line 4-686: The capabilities registry in models_capabilities.json has
empty arrays for all model entries, which prevents the sync-mcp-index.py script
from propagating capability metadata since it only processes non-empty
capability arrays. To fix this, either populate the empty capabilities arrays
with actual capability tags for each model that should be reflected in MCP
output (such as "text-to-image", "video-generation", "editing", etc.), or update
the capability propagation logic in scripts/sync-mcp-index.py to explicitly
handle and preserve models with empty capability arrays instead of silently
skipping them during metadata enrichment. Choose the approach based on whether
these models should have defined capabilities or if empty capabilities is an
intentional state that should still be reflected in the generated MCP metadata.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0169d064-046e-4c01-84aa-22efb0daa646

📥 Commits

Reviewing files that changed from the base of the PR and between c201b41 and 8c6f5e2.

📒 Files selected for processing (3)
  • scripts/models_capabilities.json
  • scripts/validate_templates.py
  • templates/index.mcp.json

Comment on lines 613 to 617
# Find all index*.json files (excluding schema and logo index)
index_files = []
for file_path in templates_dir.glob('index*.json'):
if file_path.name not in ('index.schema.json', 'index_logo.json'):
if file_path.name not in ('index.schema.json', 'index_logo.json', 'index.mcp.json'):
index_files.append(file_path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Exclusion removes all CI validation coverage for a shipped bundle artifact.

At Line 616, index.mcp.json is excluded from index-schema validation, which is fine for schema mismatch—but this script now provides no fallback validation for that file while bundles.json ships index.mcp. That creates a release gap where malformed templates/index.mcp.json can pass CI unnoticed.

Add a dedicated check for templates/index.mcp.json (at minimum: file exists, JSON parses, and top-level structure is expected) in a separate validation branch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/validate_templates.py` around lines 613 - 617, The exclusion of
index.mcp.json from index-schema validation at line 616 leaves that file
completely unchecked despite it being shipped in bundles.json, creating a
release gap. Keep the exclusion from the schema validation but add a dedicated
validation check in a separate branch that validates templates/index.mcp.json
with minimum checks: verify the file exists, verify the JSON parses
successfully, and verify the top-level structure matches expected format. This
ensures index.mcp.json receives baseline validation coverage even though it is
excluded from the schema validation loop.

…nd add default descriptions

- Added functionality to skip specific instructional categories: Node Basics, LLM, and Getting Started during MCP index export.
- Introduced default English descriptions for various included MCP categories to improve clarity and usability.
…ex.mcp.json categories

- Added a mapping from index.json group `title` to index.mcp.json `category` using INDEX_GROUP_TO_MCP_CATEGORY.
- Updated the sync logic to ignore the `category` field in index.json and handle unmapped group titles with warnings.
- Improved clarity in the output by reporting skipped unmapped titles during the sync process.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
scripts/sync-mcp-index.py (3)

215-216: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Narrow exception handling for better diagnostics.

The broad except Exception: clause hides parse errors and unexpected data structures in workflow files. While failing gracefully here is appropriate (the sync continues with fallback inference), catching specific exceptions would surface template file issues during development.

♻️ Proposed refinement
-    except Exception:
+    except (json.JSONDecodeError, KeyError, TypeError) as exc:
+        # Workflow file missing, malformed, or unexpected structure; fall back to inference
         return []

When exceptions are caught with precision and care, debugging becomes easier—a breath of fresh air!

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/sync-mcp-index.py` around lines 215 - 216, The bare `except
Exception:` clause at lines 215-216 is too broad and masks parsing errors and
unexpected data structures that would be useful for debugging workflow files
during development. Replace this broad exception handler with specific exception
catches (such as those related to JSON/YAML parsing, KeyError, TypeError, or
AttributeError) that are actually expected from malformed or unexpected workflow
data, keeping the graceful fallback of returning an empty list only for the
anticipated failure modes while allowing other unexpected exceptions to surface
for investigation.

212-212: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add explicit UTF-8 encoding for cross-platform file compatibility — a byte of prevention!

Several file operations omit the encoding parameter, relying on Python's platform-dependent default. On Windows, this can trigger UnicodeDecodeError when reading JSON files with non-ASCII characters or produce incorrectly encoded output. Since JSON is UTF-8 by convention, specify encoding="utf-8" explicitly.

🔧 Proposed fix
-        with open(wf_path) as f:
+        with open(wf_path, encoding="utf-8") as f:
-    with open(INDEX_FILE) as f:
+    with open(INDEX_FILE, encoding="utf-8") as f:
-        with open(OUTPUT_FILE) as f:
+        with open(OUTPUT_FILE, encoding="utf-8") as f:
-    with open(OUTPUT_FILE, "w") as f:
+    with open(OUTPUT_FILE, "w", encoding="utf-8") as f:

As per coding guidelines, scripts must be cross-platform compatible; explicit encoding prevents locale-dependent failures.

Also applies to: 400-401, 406-407, 534-535

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/sync-mcp-index.py` at line 212, Add explicit UTF-8 encoding to all
file open operations in the script to ensure cross-platform compatibility. At
line 212 where `with open(wf_path) as f:` appears, add `encoding="utf-8"` as a
parameter. Similarly, apply the same fix to all other file open operations
throughout the script (specifically at lines 400-401, 406-407, and 534-535 as
mentioned). This ensures JSON files and other text files are read and written
with UTF-8 encoding consistently across all platforms, preventing
UnicodeDecodeError on Windows systems.

Source: Coding guidelines


464-464: ⚠️ Potential issue | 🟡 Minor

Remove the redundant substring check on stringified tags.

The condition "API" in str(tpl.get("tags", "")) is unnecessary and unconventional. Data shows only the exact "API" tag exists—no variants like "API_ENDPOINT"—so the first check "API" in tags already covers all cases. The second check stringifies the list and performs substring matching (which would be a bug waiting to happen if such variants existed), but it's redundant when exact element matching suffices.

Simplify to just is_api = "API" in tags and remove the convoluted fallback. No need to tag-along the extra condition—it's not adding up to better code.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/sync-mcp-index.py` at line 464, The is_api assignment contains a
redundant condition that stringifies the tags list and performs substring
matching with "API" in str(tpl.get("tags", "")). Since exact element matching
with "API" in tags already covers all existing cases, remove the entire fallback
condition (the or clause with the stringification and the openSource check).
Simplify the line to just is_api = "API" in tags to use exact element matching
only, making the code more conventional and removing the unnecessary substring
check.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@scripts/sync-mcp-index.py`:
- Around line 215-216: The bare `except Exception:` clause at lines 215-216 is
too broad and masks parsing errors and unexpected data structures that would be
useful for debugging workflow files during development. Replace this broad
exception handler with specific exception catches (such as those related to
JSON/YAML parsing, KeyError, TypeError, or AttributeError) that are actually
expected from malformed or unexpected workflow data, keeping the graceful
fallback of returning an empty list only for the anticipated failure modes while
allowing other unexpected exceptions to surface for investigation.
- Line 212: Add explicit UTF-8 encoding to all file open operations in the
script to ensure cross-platform compatibility. At line 212 where `with
open(wf_path) as f:` appears, add `encoding="utf-8"` as a parameter. Similarly,
apply the same fix to all other file open operations throughout the script
(specifically at lines 400-401, 406-407, and 534-535 as mentioned). This ensures
JSON files and other text files are read and written with UTF-8 encoding
consistently across all platforms, preventing UnicodeDecodeError on Windows
systems.
- Line 464: The is_api assignment contains a redundant condition that
stringifies the tags list and performs substring matching with "API" in
str(tpl.get("tags", "")). Since exact element matching with "API" in tags
already covers all existing cases, remove the entire fallback condition (the or
clause with the stringification and the openSource check). Simplify the line to
just is_api = "API" in tags to use exact element matching only, making the code
more conventional and removing the unnecessary substring check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6f137ba0-44d2-45ee-87e5-2c34ca1fd8c5

📥 Commits

Reviewing files that changed from the base of the PR and between 8c6f5e2 and 3549bf4.

📒 Files selected for processing (2)
  • scripts/sync-mcp-index.py
  • templates/index.mcp.json

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.

3 participants