Skip to content

Conversation

@tourtourigny
Copy link
Contributor

Add new tools for MCP server and update existing ones

Modified:

  • search_types
  • search_relation_types
  • search_properties
  • get_entity_info
    They now all use triples in their search for future filters to be applied, standardize and accelerate search

Added:

  • search_space
    To find a space based on it's name or description

Added:

  • name_search_entity
    Similar to search entity with the traversals but uses names of relation instead of id of relation. Also based on the SearchTraversalInputFilter

Added:

  • new sample data
  • contains different spaces
  • entities in the new spaces are setup to test for Pluralism and Aggregation

pub entity: T,
}

const EFFECTIVE_SEARCH_RATIO: f64 = 100000.0; // Adjust this ratio based on your needs
Copy link
Contributor

Choose a reason for hiding this comment

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

Reuse the same EFFECTIVE_SEARCH_RATIO as the one from grc20-core/src/mapping/entity/semantic_search.rs so as to keep both in sync.

Suggestion: move it to grc20-core/src/mapping/mod.rs

Copy link
Contributor

Choose a reason for hiding this comment

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

This query seems very similar to the SemanticSearchQuery defined in grc20-core/src/mapping/entity/semantic_search.rs with the only difference being the threshold. Is that correct or am I missing something?

If they are the same except for threshold, then just add threshold as an optional arg to SemanticSearchQuery with a default of 0.0 (to not filter anything) and use that query instead.

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 main difference is in the filter becoming a Vec. It allows to chain Entity filters and give them an order in the query which is needed for the traversal.

Comment on lines 8 to 22
{
"attribute_name": "Name",
"attribute_value": "Works at",
"entity_id": "U1uCAzXsRSTP4vFwo1JwJG"
},
{
"attribute_name": "Is type property",
"attribute_value": "0",
"entity_id": "U1uCAzXsRSTP4vFwo1JwJG"
},
{
"attribute_name": "Name",
"attribute_value": "Works at",
"entity_id": "U1uCAzXsRSTP4vFwo1JwJG"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate triple in the example, is that on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It comes from the name being declared in more than one space. Will be handled eventually with space handling.

Comment on lines 13 to 17
{
"attribute_name": "Is type property",
"attribute_value": "0",
"entity_id": "U1uCAzXsRSTP4vFwo1JwJG"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

What is "Is type property"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

id: T2TRBTBe5NS8vR94PLhzce
It is an Entity of type ATTRIBUTE that contains a checkbox and the name is "Is type property"
Basically I think it is an artifact of the first few relations in the data

@@ -0,0 +1,25 @@
This request allows you to search by name for a basic Relation of the Knowledge Graph(KG) like Owners or Authors. This will give back the
Copy link
Contributor

Choose a reason for hiding this comment

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

This description looks incomplete. Also, why "Relation" when the tool is called "search_properties"?

@@ -0,0 +1,123 @@
This request allows you to get the detailled information about an Entity with it's ID. You will get the name, description, other attributes, inbound relations and outbound relations of the Entity.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo "detailled"

#[derive(Clone, Debug, Default, PartialEq)]
pub struct Rename {
name_pair: NamePair,
params: HashMap<String, neo4rs::BoltType>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are params ever used? If not, then remove it!

self
}

pub fn r#rename(mut self, rename: impl Into<Rename>) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to prefix the method name with r# in this case! r# is only useful where the name of the method (or variable) is a reserved keyword (e.g.: r#struct, r#type, r#where, etc.)

/// Filter used to:
/// - Traverse to inbound or outbound relation
#[derive(Clone, Debug, Default)]
pub struct TraverseRelationFilter {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to TraverseRelationSubquery since it's not strictly a "filter", but also changes the nature of the returned data.

In general, subqueries that end in "Filter" (e.g.: "TypeFilter") imply that they do not change the nature of the returned data.

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI to load the tool description you need to use include_str! in the #[tool] macro, e.g.:

#[tool(description = include_str!("../resources/search_type_description.md"))]
async fn search_types(
    &self,
    #[tool(param)]
    #[schemars(description = "The query string to search for types")]
    query: String,
) -> Result<CallToolResult, McpError> {...}

@cvauclair cvauclair merged commit 7c3a00b into main Jul 3, 2025
4 checks passed
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