Skip to main content
Glama

register_pattern

Register code patterns with detailed metadata to catalog reusable logic, style, and standards. Specify name, description, language, example, and metadata for efficient retrieval on the SourceSage MCP server.

Instructions

Register a code pattern.

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYes
exampleNo
languageNo
metadataNo
nameYes

Implementation Reference

  • Handler function for the 'register_pattern' MCP tool. Registers a code pattern in the KnowledgeGraph by calling add_pattern, optionally saves to storage, and returns the pattern ID. The decorator @self.mcp.tool() also serves as the registration.
    @self.mcp.tool()
    def register_pattern(
        name: str,
        description: str,
        language: str | None = None,
        example: str | None = None,
        metadata: dict[str, Any] | None = None,
    ) -> str:
        """Register a code pattern.
    
        Args:
            name: Name of the pattern
            description: Description of the pattern
            language: Programming language
            example: Example code demonstrating the pattern
            metadata: Additional metadata as key-value pairs
        """
        pattern_id = self.knowledge.add_pattern(
            name=name,
            description=description,
            language=language,
            example=example,
            metadata=metadata,
        )
    
        # Save knowledge if storage path is set
        if self.storage_path:
            self.knowledge.save_to_file(self.storage_path)
    
        return f"Pattern registered with ID: {pattern_id}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states 'register' which implies a write/mutation operation, but doesn't disclose behavioral traits like whether this requires authentication, what happens on duplicate names, whether registration is persistent, or what the response looks like. The description is minimal and lacks important operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose statement. The parameter documentation is organized in a clear Args section. While efficient, the parameter explanations could be more informative to better earn their place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with 5 parameters, 0% schema description coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain what 'registering' entails operationally, what happens after registration, error conditions, or how this integrates with the sibling query_patterns tool. The minimal description leaves too many contextual gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates by listing all 5 parameters with brief explanations. However, these explanations are basic (e.g., 'Name of the pattern') and don't provide deeper semantic context like format constraints, validation rules, or how metadata should be structured. The description adds value but doesn't fully compensate for the schema coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'register' and resource 'code pattern', making the purpose specific and understandable. However, it doesn't differentiate this tool from its sibling 'register_entity', 'register_relationship', and 'register_style_convention' which all use the same 'register' verb pattern for different resources.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'query_patterns' and other registration tools, there's no indication of when registration is appropriate versus querying or what distinguishes this from registering entities, relationships, or style conventions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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