search_prisma_api_docs
Quickly find relevant information in Prisma Cloud API documentation by entering your query, streamlining access to critical API details for developers.
Instructions
Search Prisma Cloud API documentation
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Input Schema (JSON Schema)
{
"properties": {
"query": {
"title": "Query",
"type": "string"
}
},
"required": [
"query"
],
"title": "search_prisma_api_docsArguments",
"type": "object"
}
Implementation Reference
- src/main.py:201-205 (handler)The main handler function for the 'search_prisma_api_docs' MCP tool. It is registered with @mcp.tool(), defines the input schema (query: str) and output (str JSON), and delegates to the DocumentationIndexer.search_docs method for the 'prisma_api' site.@mcp.tool() async def search_prisma_api_docs(query: str) -> str: """Search Prisma Cloud API documentation""" results = await indexer.search_docs(query, site='prisma_api') return json.dumps(results, indent=2)
- src/main.py:108-160 (helper)Core helper method implementing the search logic: filters by site, computes relevance scores based on title/content matches and word matches, extracts snippets, sorts results by score, limits to top 10.async def search_docs(self, query: str, site: str = None) -> List[Dict]: """Search indexed documentation""" if not self.cached_pages: return [] query_lower = query.lower() results = [] for url, page in self.cached_pages.items(): # Filter by site if specified if site and page.site != site: continue # Calculate relevance score score = 0 title_lower = page.title.lower() content_lower = page.content.lower() # Higher score for title matches if query_lower in title_lower: score += 10 # Even higher for exact title matches if query_lower == title_lower: score += 20 # Score for content matches content_matches = content_lower.count(query_lower) score += content_matches * 2 # Score for partial word matches in title query_words = query_lower.split() for word in query_words: if word in title_lower: score += 5 if word in content_lower: score += 1 if score > 0: # Extract snippet around first match snippet = self._extract_snippet(page.content, query, max_length=200) results.append({ 'title': page.title, 'url': page.url, 'site': page.site, 'snippet': snippet, 'score': score }) # Sort by relevance score (highest first) and limit results results.sort(key=lambda x: x['score'], reverse=True) return results[:10]
- src/main.py:16-27 (helper)Dataclass used to store indexed documentation pages with metadata, content, expiration logic.@dataclass class CachedPage: title: str content: str url: str site: str timestamp: float ttl: float = 3600 # 1 hour default TTL @property def is_expired(self) -> bool: return time.time() > self.timestamp + self.ttl
- server.py:197-201 (registration)Alternative registration of the tool in server.py (duplicate implementation).@mcp.tool() async def search_prisma_api_docs(query: str) -> str: """Search Prisma Cloud API documentation""" results = await indexer.search_docs(query, site='prisma_api') return json.dumps(results, indent=2)
- server.py:198-201 (handler)Duplicate handler function in server.py.async def search_prisma_api_docs(query: str) -> str: """Search Prisma Cloud API documentation""" results = await indexer.search_docs(query, site='prisma_api') return json.dumps(results, indent=2)