Skip to main content
Glama
RossH121

Perplexity MCP Server

recency_filter

Set time windows for search results to focus on recent information. Choose hour, day, week, or month filters for time-sensitive queries like news and updates.

Instructions

Control the time window for search results. Essential for time-sensitive queries like news, updates, or recent developments. Filter persists until changed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterYesTime window: 'hour' for breaking news, 'day' for daily updates, 'week' for recent developments, 'month' for broader recent context, 'none' to include all time periods

Implementation Reference

  • RecencyFilterHandler class that implements the core logic for the recency_filter tool: validates input arguments and delegates to FilterState to set the filter.
    export class RecencyFilterHandler {
    	constructor(private filterState: FilterState) {}
    
    	async handle(request: McpRequest) {
    		if (!isValidRecencyArgs(request.params.arguments)) {
    			throw ErrorHandler.createMcpError(
    				ErrorCode.InvalidParams,
    				"Invalid recency filter argument. Filter must be one of: hour, day, week, month, none."
    			);
    		}
    
    		const { filter } = request.params.arguments as RecencyArgs;
    		const resultMessage = this.filterState.setRecencyFilter(filter);
    
    		return {
    			content: [
    				{
    					type: "text",
    					text: resultMessage,
    				},
    			],
    		};
    	}
  • JSON schema definition for the recency_filter tool, including name, description, and input schema with enum validation.
    name: "recency_filter",
    description: "Control the time window for search results. Essential for time-sensitive queries like news, updates, or recent developments. Filter persists until changed.",
    inputSchema: {
    	type: "object",
    	properties: {
    		filter: {
    			type: "string",
    			enum: ["hour", "day", "week", "month", "none"],
    			description: "Time window: 'hour' for breaking news, 'day' for daily updates, 'week' for recent developments, 'month' for broader recent context, 'none' to include all time periods",
    		},
    	},
    	required: ["filter"],
    },
  • Registration of tool handlers in the MCP server's CallToolRequest handler, dispatching recency_filter to RecencyFilterHandler.handle()
    	switch (request.params.name) {
    		case "search":
    			return this.searchHandler.handle(request);
    		case "domain_filter":
    			return this.domainFilterHandler.handle(request);
    		case "recency_filter":
    			return this.recencyFilterHandler.handle(request);
    		case "clear_filters":
    			return this.filterManagementHandler.handleClearFilters();
    		case "list_filters":
    			return this.filterManagementHandler.handleListFilters();
    		case "model_info":
    			return this.modelInfoHandler.handle(request);
    		default:
    			throw new McpError(
    				ErrorCode.MethodNotFound,
    				`Unknown tool: ${request.params.name}`
    			);
    	}
    });
  • Instantiation of RecencyFilterHandler instance in PerplexityMcpServer constructor.
    this.recencyFilterHandler = new RecencyFilterHandler(this.filterState);
  • FilterState.setRecencyFilter method, which stores the recency filter value and generates the response message used by the handler.
    setRecencyFilter(filter: string): string {
    	if (filter === "none") {
    		this.recencyFilter = null;
    		return "Recency filter has been disabled. Searches will include results from any time period.";
    	}
    
    	this.recencyFilter = filter;
    	const timeDescription = {
    		hour: "hour",
    		day: "24 hours", 
    		week: "7 days",
    		month: "30 days"
    	}[filter] || filter;
    
    	return `Recency filter set to "${filter}". Searches will be limited to content from the last ${timeDescription}.`;
    }

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