Skip to content

Feature/mcp create metric#26089

Merged
Vishnuujain merged 6 commits intomainfrom
feature/mcp-create-metric
Feb 26, 2026
Merged

Feature/mcp create metric#26089
Vishnuujain merged 6 commits intomainfrom
feature/mcp-create-metric

Conversation

@Vishnuujain
Copy link
Contributor

@Vishnuujain Vishnuujain commented Feb 25, 2026

Describe your changes:

Fixes #26016

I worked on ... because ...

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

Summary by Gitar

  • New MCP tool: Added CreateMetricTool to enable AI agents to create Metric entities with configurable expressions (SQL, Python, Java, JavaScript), types, granularities, and units of measurement
  • Integration & schema: Registered tool in DefaultToolContext dispatcher and added comprehensive parameter definitions to tools.json with validation guidance
  • Error logging improvements: Enhanced exception logging in CommonUtils and DefaultToolContext with structured message placeholders and full exception context

This will update automatically on new commits.

@github-actions
Copy link
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@github-actions
Copy link
Contributor

The Java checkstyle failed.

Please run mvn spotless:apply in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Java code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

Co-authored-by: Vishnuujain <Vishnuujain@users.noreply.github.com>
@gitar-bot
Copy link

gitar-bot bot commented Feb 25, 2026

Code Review ✅ Approved 1 resolved / 1 findings

Well-structured CreateMetricTool implementation following established GlossaryTool patterns. The previous unchecked cast issue has been fixed with proper instanceof guards on all parameters. Logging improvements in CommonUtils and DefaultToolContext are solid additions.

✅ 1 resolved
Edge Case: Unchecked casts on required params may throw ClassCastException

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CreateMetricTool.java:59
Lines 59-60 use direct (String) casts for the required metricExpressionLanguage and metricExpressionCode parameters. If an MCP client sends a non-string value (e.g., an integer or object), this will throw an unhelpful ClassCastException instead of the well-formatted IllegalArgumentException that name gets (lines 43-47).

The name parameter already demonstrates the safer pattern using instanceof String with pattern matching. The same approach should be applied to the other required parameters for consistency and better error messages. The same concern applies to the optional String parameters on lines 52-57, 80, 91, 102, and 113, though these are lower risk since they're optional.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@Vishnuujain Vishnuujain merged commit a6556b9 into main Feb 26, 2026
43 of 44 checks passed
@Vishnuujain Vishnuujain deleted the feature/mcp-create-metric branch February 26, 2026 16:35
@github-actions
Copy link
Contributor

Changes have been cherry-picked to the 1.12.2 branch.

github-actions bot pushed a commit that referenced this pull request Feb 26, 2026
* feat(mcp): add create_metric tool to OpenMetadata MCP server

* fix(mcp): make metricExpression required in create_metric tool

* fix(mcp): add domains field to create_metric tool

* fix(mcp): improve patch_entity field path guidance

* style(mcp): apply spotless formatting

* fix: add type checking for required params in CreateMetricTool

Co-authored-by: Vishnuujain <Vishnuujain@users.noreply.github.com>

---------

Co-authored-by: Gitar <noreply@gitar.ai>
Co-authored-by: Vishnuujain <Vishnuujain@users.noreply.github.com>
(cherry picked from commit a6556b9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add new MCP tool for metrics

3 participants