Skip to main content
Glama
RossH121

Perplexity MCP Server

domain_filter

Configure domain filtering for search results to prioritize trusted sources or exclude unreliable ones, with filters persisting across searches.

Instructions

Configure domain filtering for search results. Use 'allow' to prioritize trusted sources (e.g., documentation sites, academic domains) or 'block' to exclude unreliable sources. Maximum 20 domains total. Filters persist across searches until cleared.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesDomain name without protocol. Examples: 'wikipedia.org', 'docs.python.org', 'arxiv.org'. For subdomains: 'api.example.com'
actionYes'allow' prioritizes this domain in results, 'block' excludes it completely

Implementation Reference

  • DomainFilterHandler class implementing the core logic for the domain_filter tool: validation, state update, and response formatting.
    export class DomainFilterHandler { constructor(private filterState: FilterState) {} async handle(request: McpRequest) { if (!isValidDomainArgs(request.params.arguments)) { throw ErrorHandler.createMcpError( ErrorCode.InvalidParams, 'Invalid domain filter arguments. Domain must be a non-empty string and action must be "allow" or "block".' ); } const { domain, action } = request.params.arguments as DomainArgs; const resultMessage = this.filterState.setDomainFilter(domain, action); return { content: [ { type: "text", text: resultMessage, }, ], }; }
  • Schema definition for the domain_filter tool including name, description, and input validation schema.
    { name: "domain_filter", description: "Configure domain filtering for search results. Use 'allow' to prioritize trusted sources (e.g., documentation sites, academic domains) or 'block' to exclude unreliable sources. Maximum 20 domains total. Filters persist across searches until cleared.", inputSchema: { type: "object", properties: { domain: { type: "string", description: "Domain name without protocol. Examples: 'wikipedia.org', 'docs.python.org', 'arxiv.org'. For subdomains: 'api.example.com'", }, action: { type: "string", enum: ["allow", "block"], description: "'allow' prioritizes this domain in results, 'block' excludes it completely", }, }, required: ["domain", "action"], }, },
  • Registration of domain_filter tool handler in the MCP server's CallToolRequestSchema handler (switch dispatch).
    case "domain_filter": return this.domainFilterHandler.handle(request);
  • Registration of tool schemas via TOOL_SCHEMAS in ListToolsRequestSchema handler.
    tools: TOOL_SCHEMAS, }));
  • Core helper method setDomainFilter that manages allowed and blocked domains state, cleans input, handles add/remove logic, and returns status message.
    setDomainFilter(domain: string, action: "allow" | "block"): string { // Clean the domain input - remove any protocol prefixes const cleanDomain = domain .replace(/^https?:\/\//, "") .split("/")[0] .trim(); if (action === "allow") { // Remove from blocked if it exists there this.domainFilters.blockedDomains = this.domainFilters.blockedDomains.filter( (d) => d !== cleanDomain ); // Add to allowed if not already there if (!this.domainFilters.allowedDomains.includes(cleanDomain)) { this.domainFilters.allowedDomains.push(cleanDomain); } return `Added ${cleanDomain} to allowed domains. Search results will prioritize this domain.`; } else { // Remove from allowed if it exists there this.domainFilters.allowedDomains = this.domainFilters.allowedDomains.filter( (d) => d !== cleanDomain ); // Add to blocked if not already there if (!this.domainFilters.blockedDomains.includes(cleanDomain)) { this.domainFilters.blockedDomains.push(cleanDomain); } return `Added ${cleanDomain} to blocked domains. Search results will exclude this domain.`; } }

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/RossH121/perplexity-mcp'

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