WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@cyberkunju
Copy link

Summary

The registry validator had a blind spot: while isConfigEnvValid() enforces that environment variable templates are namespaced with the server name, there was no equivalent guard for server.Run.Volumes. As a result, any volume mapping could reference parameters from a completely different server and still pass validation, only to explode later at runtime with an opaque Docker error.

Problem

Here’s the kind of misconfiguration we were silently accepting:

name: my-server
image: mcp/my-server
type: server
run:
  volumes:
    - '{{wrong-name.storage_path}}:/app/data'  # Wrong prefix!
config:
  parameters:
    type: object
    properties:
      storage_path:
        type: string

Because nothing double-checked server.Run.Volumes, {{wrong-name.storage_path}} skated by unchecked. When Docker spun up the container it couldn’t resolve that parameter and failed with a cryptic message.

Impact

More than twenty production servers rely on templated volumes today, including:

  • arxiv-mcp-server{{arxiv-mcp-server.storage_path}}:/app/papers
  • markdownify{{markdownify.paths|volume|into}}
  • aks{{aks.azure_dir}}:/home/mcp/.azure

Any typo in those prefixes would have slipped through CI and landed in the registry, leaving operators to discover the failure only after deployment.

Solution

  • Introduced isRunVolumesValid() to mirror the existing environment validation rules.
  • Enforce that every template is prefixed with the current server name, whether it’s a bare parameter ({{server.param}}) or a filtered expression ({{server.param|filter|into}}).
  • Emit clear, actionable error messages that call out the expected prefix versus what we actually saw.

Before

$ go run ./cmd/validate --name my-server
✅ Config env is valid
✅ License validation skipped
# Invalid volume parameter silently accepted!

After

$ go run ./cmd/validate --name my-server
✅ Config env is valid
2025/10/10 volume parameter must be prefixed with "my-server." but found "wrong-name.storage_path" in: "{{wrong-name.storage_path}}:/app/data"
exit status 1

Testing

  • New coverage: Unit tests spanning valid prefixes, filter expressions, and edge cases.
  • Stability fixes: Cleaned up existing tests to assert on the improved error handling.
  • Validation sweep: Confirmed arxiv-mcp-server, markdownify, and aks all pass with the new guardrails.

This closes the validation gap and surfaces configuration mistakes where they belong—in CI, not in production.

@cyberkunju cyberkunju requested a review from a team as a code owner October 10, 2025 19:43
Copilot AI review requested due to automatic review settings December 6, 2025 07:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a critical validation gap where volume parameter templates in server configurations could reference parameters from different servers without validation, leading to runtime failures. The fix introduces server name prefix validation for volume parameters, matching the existing validation pattern used for environment variables.

Key Changes:

  • Added isRunVolumesValid() function to validate volume parameter prefixes
  • Integrated volume validation into the main validation flow
  • Added comprehensive test coverage for volume validation scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
cmd/validate/main.go Implements isRunVolumesValid() to enforce server name prefix requirements for volume parameters and integrates it into the validation pipeline
cmd/validate/main_test.go Adds test coverage for volume validation and updates Test_areSecretsValid with proper working directory setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return nil
}

// Check volume parameter usage is valid
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

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

The comment should follow Go conventions by starting with the function name. Change to: // isRunVolumesValid checks volume parameter usage is valid

Suggested change
// Check volume parameter usage is valid
// isRunVolumesValid checks volume parameter usage is valid

Copilot uses AI. Check for mistakes.
Comment on lines +294 to +298
// Skip if it's a filter expression (contains |)
paramContent := param[2 : len(param)-2]
if strings.Contains(paramContent, "|") {
// Extract just the parameter name before the first |
paramName := strings.Split(paramContent, "|")[0]
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

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

The comment on line 294 is misleading - the code doesn't skip filter expressions but rather handles them specially. Update to: // Handle filter expressions (contains |) by extracting the parameter name before the first |

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +117
// Change to repo root for tests
originalWd, err := os.Getwd()
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

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

The directory setup logic is duplicated between Test_areSecretsValid and Test_isRunVolumesValid. Consider extracting this into a helper function or using t.TempDir() with test fixtures to improve maintainability.

Copilot uses AI. Check for mistakes.
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.

1 participant