Skip to content

feat: add filterQuery support to mcp catalog#2283

Merged
google-oss-prow[bot] merged 5 commits intokubeflow:mainfrom
Al-Pragliola:al-pragliola-filterquery-mcp
Mar 2, 2026
Merged

feat: add filterQuery support to mcp catalog#2283
google-oss-prow[bot] merged 5 commits intokubeflow:mainfrom
Al-Pragliola:al-pragliola-filterquery-mcp

Conversation

@Al-Pragliola
Copy link
Contributor

@Al-Pragliola Al-Pragliola commented Feb 26, 2026

Description

depends on #2278

This PR introduces enhanced filtering capabilities to the MCP catalog service, allowing users to search and filter catalog items more effectively.

Key Changes:

  • Added filterquery functionality to the MCP catalog service
  • Implemented new database models and API endpoints for MCP server tools
  • Added comprehensive unit tests to ensure reliability

How Has This Been Tested?

  🔧 Basic Server Listings

  # List all MCP servers
  curl -s "http://localhost:8081/api/mcp_catalog/v1alpha1/mcp_servers" | jq .

  # Get specific server details
  curl -s "http://localhost:8081/api/mcp_catalog/v1alpha1/mcp_servers/3" | jq .

  🔍 Working Filter Examples

  1. Filter by Provider:
  curl -s "http://localhost:8081/api/mcp_catalog/v1alpha1/mcp_servers?filterQuery=provider%20%3D%20%27OpenAI%27" | jq .
  # Returns: openai-assistant

  2. Filter by License:
  curl -s "http://localhost:8081/api/mcp_catalog/v1alpha1/mcp_servers?filterQuery=license%20%3D%20%27MIT%27" | jq '.items[].name'
  # Returns: "openai-assistant", "file-manager"

  3. LIKE Pattern Matching:
  curl -s "http://localhost:8081/api/mcp_catalog/v1alpha1/mcp_servers?filterQuery=description%20LIKE%20%27%25SQL%25%27" | jq '.items[].name'
  # Returns: "database-connector"

  4. Complex OR Query:
  curl -s "http://localhost:8081/api/mcp_catalog/v1alpha1/mcp_servers?filterQuery=(license%20%3D%20%27MIT%27%20OR%20license%20%3D%20%27Apache-2.0%27)" | jq '.items | length'
  # Returns: 3 servers

  5. Sorting and Ordering:
  curl -s "http://localhost:8081/api/mcp_catalog/v1alpha1/mcp_servers?orderBy=name&sortOrder=ASC" | jq '.items[].name'
  # Returns: names in alphabetical order

  🛠️  Tool Filtering Examples

  6. List Tools for Server:
  curl -s "http://localhost:8081/api/mcp_catalog/v1alpha1/mcp_servers/3/tools" | jq .
  # Returns: chat_completion, embeddings tools

  7. Filter Tools by Description:
  curl -s "http://localhost:8081/api/mcp_catalog/v1alpha1/mcp_servers/3/tools?filterQuery=description%20LIKE%20%27%25chat%25%27" | jq '.items[].name'
  # Returns: "openai-assistant@1.2.0:chat_completion"

test data

mcp_servers:
  - name: openai-assistant
    description: "OpenAI Assistant MCP server for AI-powered conversations"
    provider: "OpenAI"
    version: "1.2.0"
    license: "MIT"
    tags: ["ai", "assistant", "openai", "gpt"]
    tools:
      - name: chat_completion
        description: "Generate chat completions using OpenAI models"
      - name: embeddings
        description: "Generate embeddings for text"

  - name: github-integration
    description: "GitHub MCP server for repository management"
    provider: "GitHub Inc"
    version: "2.1.3"
    license: "Apache-2.0"
    tags: ["git", "github", "repository", "version-control"]
    tools:
      - name: create_issue
        description: "Create a new GitHub issue"
      - name: list_repositories
        description: "List user repositories"
      - name: create_pull_request
        description: "Create a new pull request"

  - name: database-connector
    description: "Database MCP server for SQL operations"
    provider: "DB Corp"
    version: "3.0.1"
    license: "GPL-3.0"
    tags: ["database", "sql", "postgres", "mysql"]
    tools:
      - name: execute_query
        description: "Execute SQL queries"
      - name: list_tables
        description: "List database tables"

  - name: file-manager
    description: "File system operations MCP server"
    provider: "Local Systems Inc"
    version: "1.0.0"
    license: "MIT"
    tags: ["filesystem", "files", "local"]
    tools:
      - name: read_file
        description: "Read contents of a file"
      - name: write_file
        description: "Write content to a file"
      - name: list_directory
        description: "List directory contents"

Merge criteria:

  • All the commits have been signed-off (To pass the DCO check)
  • The commits have meaningful messages
  • Automated tests are provided as part of the PR for major new functionalities; testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work.
  • Code changes follow the kubeflow contribution guidelines.
  • For first time contributors: Please reach out to the Reviewers to ensure all tests are being run, ensuring the label ok-to-test has been added to the PR.

Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
@Al-Pragliola Al-Pragliola force-pushed the al-pragliola-filterquery-mcp branch from f9d6ac5 to e1a7c7b Compare February 27, 2026 10:28
@Al-Pragliola Al-Pragliola marked this pull request as ready for review February 27, 2026 14:26
@google-oss-prow google-oss-prow bot requested a review from tarilabs February 27, 2026 14:26
@Al-Pragliola Al-Pragliola requested review from pboyd and removed request for tarilabs February 27, 2026 14:26
Copy link
Member

@pboyd pboyd left a comment

Choose a reason for hiding this comment

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

A few nits, but this looks really good.

/lgtm

Comment on lines +13 to +16
RestEntityCatalogModel CatalogRestEntityType = "CatalogModel"
RestEntityCatalogArtifact CatalogRestEntityType = "CatalogArtifact"
RestEntityMCPServer CatalogRestEntityType = "MCPServer"
RestEntityMCPServerTool CatalogRestEntityType = "MCPServerTool"
Copy link
Member

Choose a reason for hiding this comment

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

Should these replace the versions in models?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the other way around 😁

ApplyListFilters: applyMCPServerToolListFilters,
IsNewEntity: func(entity models.MCPServerTool) bool { return entity.GetID() == nil },
HasCustomProperties: func(entity models.MCPServerTool) bool { return entity.GetCustomProperties() != nil },
EntityMappingFuncs: filter.NewCatalogEntityMappings(),
Copy link
Member

Choose a reason for hiding this comment

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

Is PreserveHistoricalTimes still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is, forgot to add it to the server tool. If you mean in general if we need it, I think we do so that if a timestamp is present in the yaml data we keep it

Copy link
Member

Choose a reason for hiding this comment

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

I just meant for MCPServerToolRepository specifically.

Comment on lines +72 to +80
if err != nil {
statusCode := http.StatusInternalServerError
if strings.Contains(fmt.Sprintf("%v", err), "not found") {
statusCode = http.StatusNotFound
} else if strings.Contains(fmt.Sprintf("%v", err), "invalid") {
statusCode = http.StatusBadRequest
}
return ErrorResponse(statusCode, err), err
}
Copy link
Member

Choose a reason for hiding this comment

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

Would ErrorToStatus (pkg/api/error.go) help here?


// FindMCPServers - List MCP servers.
func (m *MCPCatalogServiceAPIService) FindMCPServers(ctx context.Context, name string, q string, sourceLabel []string, filterQuery string, namedQuery string, includeTools bool, toolLimit int32, pageSize string, orderBy model.OrderByField, sortOrder model.SortOrder, nextPageToken string) (ImplResponse, error) {
var err error
Copy link
Member

Choose a reason for hiding this comment

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

It's not hurting anything, but this doesn't seem to be needed.

Suggested change
var err error


// FindMCPServerTools - List MCP server tools.
func (m *MCPCatalogServiceAPIService) FindMCPServerTools(ctx context.Context, serverID string, filterQuery string, pageSize string, orderBy model.OrderByField, sortOrder model.SortOrder, nextPageToken string) (ImplResponse, error) {
var err error
Copy link
Member

Choose a reason for hiding this comment

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

This one too.

Suggested change
var err error

Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
@google-oss-prow google-oss-prow bot removed the lgtm label Mar 2, 2026
@Al-Pragliola Al-Pragliola requested a review from pboyd March 2, 2026 10:31
Copy link
Member

@pboyd pboyd left a comment

Choose a reason for hiding this comment

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

/lgtm

@google-oss-prow google-oss-prow bot added the lgtm label Mar 2, 2026
Copy link
Contributor

@chambridge chambridge left a comment

Choose a reason for hiding this comment

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

lgtm

@pboyd
Copy link
Member

pboyd commented Mar 2, 2026

/approve

@google-oss-prow
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pboyd

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot merged commit e8537d3 into kubeflow:main Mar 2, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants