query_style_conventions
Retrieve coding style conventions from SourceSage’s knowledge graph by specifying language or convention name. Simplify adherence to code standards across projects.
Instructions
Query coding style conventions in the knowledge graph.
Args: language: Filter by programming language convention_name: Filter by convention name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| convention_name | No | ||
| language | No |
Implementation Reference
- sourcesage/mcp_server.py:397-435 (handler)The MCP tool handler function for 'query_style_conventions'. Registered via @self.mcp.tool() decorator. Implements the core logic: queries the KnowledgeGraph helper method, formats results into a readable string output.@self.mcp.tool() def query_style_conventions( language: str | None = None, convention_name: str | None = None ) -> str: """Query coding style conventions in the knowledge graph. Args: language: Filter by programming language convention_name: Filter by convention name """ conventions = self.knowledge.find_style_conventions( name=convention_name, language=language ) if not conventions: return "No style conventions found matching the query criteria" # Format results output = f"Found {len(conventions)} style conventions:\n\n" for convention in conventions: output += f"Name: {convention.name}\n" if convention.language: output += f"Language: {convention.language}\n" output += f"Description: {convention.description}\n" if convention.examples: output += "Examples:\n" for i, example in enumerate(convention.examples): output += f"Example {i + 1}:\n" output += "```\n" output += example output += "\n```\n" output += "\n" return output
- sourcesage/knowledge.py:420-440 (helper)Helper method in KnowledgeGraph class that retrieves style conventions matching the given name and/or language filters. Called by the tool handler to fetch the data.def find_style_conventions( self, name: str | None = None, language: str | None = None ) -> list[StyleConvention]: """Find style conventions by name and/or language. Args: name: Optional convention name to search for language: Optional language to filter by Returns: List of matching conventions """ results = [] for convention in self.style_conventions.values(): if (name is None or convention.name == name) and ( language is None or convention.language == language ): results.append(convention) return results