Skip to main content
Glama

register_style_convention

Define and store coding style conventions for consistency across projects. Specify name, description, language, examples, and metadata to standardize code formatting practices.

Instructions

Register a coding style convention.

Args: name: Name of the convention description: Description of the convention language: Programming language examples: Example code snippets demonstrating the convention metadata: Additional metadata as key-value pairs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYes
examplesNo
languageNo
metadataNo
nameYes

Implementation Reference

  • The handler function decorated as an MCP tool that registers a style convention by calling KnowledgeGraph.add_style_convention and saves the knowledge graph if a storage path is configured.
    @self.mcp.tool() def register_style_convention( name: str, description: str, language: str | None = None, examples: list[str] | None = None, metadata: dict[str, Any] | None = None, ) -> str: """Register a coding style convention. Args: name: Name of the convention description: Description of the convention language: Programming language examples: Example code snippets demonstrating the convention metadata: Additional metadata as key-value pairs """ convention_id = self.knowledge.add_style_convention( name=name, description=description, language=language, examples=examples, metadata=metadata, ) # Save knowledge if storage path is set if self.storage_path: self.knowledge.save_to_file(self.storage_path) return f"Style convention registered with ID: {convention_id}"
  • Dataclass defining the structure and fields for StyleConvention objects stored in the knowledge graph.
    class StyleConvention: """A coding style convention identified in the codebase.""" # Basic identification convention_id: str name: str description: str # Convention details language: str | None = None examples: list[str] = field(default_factory=list) # Metadata metadata: dict[str, Any] = field(default_factory=dict) # Timestamps created_at: float = field(default_factory=time.time) updated_at: float = field(default_factory=time.time)
  • KnowledgeGraph method that implements the core logic for adding a style convention to the graph by instantiating a StyleConvention and storing it in self.style_conventions.
    def add_style_convention( self, name: str, description: str, language: str | None = None, examples: list[str] | None = None, metadata: dict[str, Any] | None = None, ) -> str: """Add a style convention to the knowledge graph. Args: name: The name of the convention description: Description of the convention language: The programming language examples: Examples of the convention metadata: Additional metadata Returns: The ID of the new convention """ convention_id = self._generate_id("convention") convention = StyleConvention( convention_id=convention_id, name=name, description=description, language=language, examples=examples or [], metadata=metadata or {}, ) self.style_conventions[convention_id] = convention return convention_id
  • The @self.mcp.tool() decorator registers the register_style_convention function as an MCP tool within the _setup_tools method.
    # Style convention registration tool

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sarathsp06/sourcesage'

If you have feedback or need assistance with the MCP directory API, please join our Discord server