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}"

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