Skip to content

feat: namespace parsing validation #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 41 commits into
base: remote-verification
Choose a base branch
from

Conversation

aphansal123
Copy link
Collaborator

@aphansal123 aphansal123 commented Aug 1, 2025

Closes #22238

Namespace Parsing Validation and Server Status Management

This PR implements namespace parsing validation for domain-scoped server names and adds server status lifecycle management functionality to the MCP Metaregistry.

Motivation and Context

The MCP Metaregistry needs to support domain-scoped namespaces (e.g., com.github/my-server) to prevent namespace squatting and provide better organization. This change introduces:

  1. Namespace Validation: Implements parsing and validation for domain-scoped namespaces using reverse domain notation
  2. Server Status Management: Adds lifecycle status tracking (active/deprecated) to help users identify maintained vs. unmaintained servers
  3. Reserved Namespace Protection: Prevents use of reserved domains like localhost, example, test, etc.
  4. Domain Authentication Preparation: Lays groundwork for domain ownership verification system

How Has This Been Tested?

  • Added comprehensive unit tests for namespace parsing and validation (internal/namespace/namespace_test.go)
  • Added integration tests for publish handler namespace validation (internal/api/handlers/v0/publish_namespace_test.go)
  • Tested various namespace formats:
    • Valid domain-scoped: com.github/my-server, org.apache.commons/utility
    • Invalid formats: forward notation, missing components, reserved domains
    • Legacy compatibility: existing io.github.* patterns still work
  • Updated JSON schema validation with status field
  • Updated publisher tool to support status parameter

Breaking Changes

Non-breaking changes:

  • Existing server names continue to work (backward compatibility maintained)
  • New status field is optional and defaults to "active"
  • Legacy namespace formats are still accepted during transition period

Future breaking change preparation:

  • Strict domain-scoped validation will be enforced in future versions
  • Domain verification system will be required for custom domains

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Key Implementation Details

  • Namespace Package: New internal/namespace package handles all domain-scoped namespace parsing and validation
  • Status Field: Added ServerStatus enum with active and deprecated values across models, schemas, and examples
  • Authentication Logic: Updated publish handler to use domain-based authentication selection (currently defaults to GitHub auth for all custom domains pending domain verification implementation)
  • Reserved Domains: Comprehensive list of reserved namespaces prevents misuse of common test/example domains

Future Work

  • Domain ownership verification system (DNS TXT records and HTTP-01 challenges as documented in server-name-verification.md)
  • Stricter enforcement of domain-scoped format requirements
  • Integration with domain verification for authentication

Files Changed

  • New namespace parsing and validation system
  • Updated server models with status field
  • Enhanced publish handler with namespace validation
  • Updated JSON schemas and OpenAPI specs
  • Enhanced publisher CLI tool

aphansal123 and others added 30 commits July 29, 2025 15:27
@aphansal123 aphansal123 requested a review from Copilot August 1, 2025 21:33
Copilot

This comment was marked as outdated.

@aphansal123 aphansal123 changed the base branch from main to feature/dns-record-verification August 1, 2025 22:09
@aphansal123 aphansal123 requested a review from Copilot August 1, 2025 22:10
Copilot

This comment was marked as resolved.

@aphansal123 aphansal123 changed the title Feature/namespace parsing validation feat: namespace parsing validation Aug 3, 2025
@aphansal123 aphansal123 changed the base branch from feature/dns-record-verification to main August 3, 2025 22:38
@aphansal123 aphansal123 changed the base branch from main to feature/dns-record-verification August 3, 2025 22:38
Base automatically changed from feature/dns-record-verification to remote-verification August 3, 2025 22:40
@aphansal123 aphansal123 marked this pull request as ready for review August 4, 2025 21:28
@aphansal123 aphansal123 requested a review from Copilot August 5, 2025 16:09
Copilot

This comment was marked as outdated.

@aphansal123 aphansal123 requested a review from Copilot August 5, 2025 17:17
Copy link
Contributor

@Copilot 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 implements namespace parsing validation for domain-scoped server names (e.g., com.github/my-server) and adds server status lifecycle management (active/deprecated) to the MCP Metaregistry.

  • Introduces comprehensive namespace validation with support for reverse domain notation and reserved namespace protection
  • Adds server status field across all models, schemas, and examples to track lifecycle state
  • Updates tooling to support the new status parameter in publisher CLI and validation utilities

Reviewed Changes

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

Show a summary per file
File Description
internal/namespace/namespace.go New package implementing domain-scoped namespace parsing, validation, and reserved domain checking
internal/namespace/namespace_test.go Comprehensive test suite for namespace parsing and validation functionality
internal/model/model.go Adds ServerStatus enum and status field to Server model
internal/api/handlers/v0/publish.go Updates publish handler with namespace validation and domain-based authentication logic
internal/api/handlers/v0/publish_namespace_test.go Integration tests for namespace validation in publish handler
tools/publisher/main.go Enhances publisher CLI tool with status parameter validation and support
tools/publisher/server.json Updates template with new status field
tools/validate-examples/main.go Updates expected example count and import alias
tools/validate-schemas/main.go Updates import alias for consistency
docs/server-registry-api/openapi.yaml Adds status field to OpenAPI schema definition
docs/server-registry-api/examples.md Updates all examples with status field
docs/server-json/schema.json Adds status field to JSON schema
docs/server-json/examples.md Updates examples and adds deprecated server example

@@ -14,15 +14,15 @@ import (
"regexp"
"strings"

"github.com/santhosh-tekuri/jsonschema/v5"
jsonschema "github.com/santhosh-tekuri/jsonschema/v5"
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

[nitpick] The import alias jsonschema is redundant since the package name is already jsonschema. Consider using a more specific alias like schema or remove the alias entirely to use the default package name.

Suggested change
jsonschema "github.com/santhosh-tekuri/jsonschema/v5"
"github.com/santhosh-tekuri/jsonschema/v5"

Copilot uses AI. Check for mistakes.

@@ -13,7 +13,7 @@ import (
"path/filepath"
"strings"

"github.com/santhosh-tekuri/jsonschema/v5"
jsonschema "github.com/santhosh-tekuri/jsonschema/v5"
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

[nitpick] The import alias jsonschema is redundant since the package name is already jsonschema. Consider using a more specific alias like schema or remove the alias entirely to use the default package name.

Suggested change
jsonschema "github.com/santhosh-tekuri/jsonschema/v5"
"github.com/santhosh-tekuri/jsonschema/v5"

Copilot uses AI. Check for mistakes.

// as the domain might be newly registered or not yet propagated
// This is just a basic sanity check for obvious invalid domains
}

Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

DNS lookups can be slow and may block execution. Consider removing this network call during validation or making it optional/async, especially since the comment indicates it's a soft validation that doesn't affect the result.

Suggested change

Copilot uses AI. Check for mistakes.

http.Error(w, "Invalid namespace: "+err.Error(), http.StatusBadRequest)
return
}
// For legacy formats, we'll allow them to pass through for now
Copy link
Member

Choose a reason for hiding this comment

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

I am a bit confused by the "legacy format" here - what is this for?

Copy link
Member

Choose a reason for hiding this comment

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

From a skim to me here, it seems like it's referring to "legacy" as Legacy io.github format, but I agree that's odd; it's not legacy, we intend to support it indefinitely (and in fact have a mechanism to potentially extend it to also support e.g. com.gitlab.{user} etc. So I'd call it something more like Psuedo-domain io.github format or Borrowed domain

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense that this isn't a legacy format, @claude Please fix the comment here to reflect that this is a pseudo-domain io.github format/borrowed domain.

@aphansal123
Copy link
Collaborator Author

@claude Can you please fix the comment on line 65 in publish.go to reflect that this is a pseudo-domain io.github format/borrowed domain?

Copy link
Contributor

claude bot commented Aug 8, 2025

Claude finished @aphansal123's task —— View job


I'll help you fix the comment on line 65 in publish.go to properly reflect that this is a pseudo-domain io.github format rather than a legacy format.

Todo List

  • Read the current publish.go file to understand the context around line 65
  • Update the comment to reflect pseudo-domain/borrowed domain format
  • Commit and push the change
Progress Details

Completed!

I've successfully updated the comment on lines 65-66 in internal/api/handlers/v0/publish.go:

Before:

// For legacy formats, we'll allow them to pass through for now
// This provides backward compatibility while encouraging new domain-scoped formats

After:

// For pseudo-domain io.github format/borrowed domain, we'll allow them to pass through
// This provides support for the borrowed io.github domain while encouraging new domain-scoped formats

The comment now accurately reflects that io.github is a pseudo-domain/borrowed domain format that's intended to be supported indefinitely, rather than a legacy format that might be deprecated in the future.

Changes committed and pushed to the feature/namespace-parsing-validation branch.


The comment on line 65-66 in publish.go has been updated to clarify
that io.github is a pseudo-domain/borrowed domain format rather than
a legacy format, as it's intended to be supported indefinitely.

Co-authored-by: Ameya Phansalkar <[email protected]>
@aphansal123 aphansal123 requested a review from tadasant August 8, 2025 15:43
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