find_kubernetes_examples
Search Bear notes for Kubernetes manifest examples by resource type, such as deployment, service, or configmap, to quickly retrieve relevant configurations.
Instructions
Find Kubernetes manifest examples in Bear notes
Args: resource_type: Kubernetes resource type to search for (deployment, service, configmap, etc.)
Returns: Notes containing Kubernetes examples
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resource_type | No | deployment |
Implementation Reference
- main.py:205-245 (handler)The handler function for the 'find_kubernetes_examples' tool. Decorated with @mcp.tool() for registration. Searches Bear notes for Kubernetes resource examples using multiple search terms, deduplicates results, extracts code blocks, and returns up to 20 matching notes with additional metadata.@mcp.tool() def find_kubernetes_examples(resource_type: str = "deployment") -> List[Dict[str, Any]]: """ Find Kubernetes manifest examples in Bear notes Args: resource_type: Kubernetes resource type to search for (deployment, service, configmap, etc.) Returns: Notes containing Kubernetes examples """ try: # Search for Kubernetes-related terms k8s_terms = [ f"kind: {resource_type.title()}", f"apiVersion:", f"kubernetes {resource_type}", f"k8s {resource_type}", f"kubectl", "yaml", "manifest" ] results = [] seen_ids = set() for term in k8s_terms: notes = search_notes(term, limit=10) for note in notes: if note["id"] not in seen_ids: # Extract code blocks if present code_blocks = extract_code_blocks(note["content"]) note["code_blocks"] = code_blocks note["has_yaml"] = any("yaml" in block["language"].lower() for block in code_blocks) results.append(note) seen_ids.add(note["id"]) return results[:20] # Limit to 20 results except Exception as e: return [{"error": f"Error searching Kubernetes examples: {str(e)}"}]
- main.py:137-152 (helper)Helper function used by find_kubernetes_examples to extract code blocks (including YAML fenced blocks) from note content for analysis.def extract_code_blocks(content: str) -> List[Dict[str, str]]: """Extract code blocks from note content""" import re # Find code blocks with language specification code_blocks = [] pattern = r'```(\w+)?\n(.*?)```' matches = re.findall(pattern, content, re.DOTALL) for language, code in matches: code_blocks.append({ "language": language or "text", "code": code.strip() }) return code_blocks