
Build an MCP Search Tool with Prismfy for cleaner search integrations.
Prismfy Team
May 7, 2026
This tutorial focuses on a production-friendly search integration pattern, so developers can add a web search tool, fresh public evidence, and better routing logic without overbuilding retrieval.
MCP works best when tools are narrow and well named. A search tool should search. It should not pretend to be a browser, a scraper, or a full agent platform.
Prismfy fits that boundary. Your MCP tool can take a natural-language query, send one POST /v1/search request, and return a compact evidence set that the model can reason over. That gives the assistant current public context without pushing retrieval logic into the prompt.
This is especially useful for questions that depend on changing public pages: docs, changelogs, release notes, pricing pages, and company pages.
Models are strongest when the evidence layer is explicit. An MCP tool is one of the cleanest places to make that explicit because the client already expects structured inputs and outputs.
If you skip the search layer, the model will try to answer from memory. If you make the tool too broad, it becomes hard to debug. A single-purpose search tool is usually the right middle ground.
The pattern is simple.
prismfy_search.POST /v1/search.The model can then cite those sources or ask for a narrower query if the results are weak.
The following TypeScript example shows the core of the tool handler. It uses plain fetch, so the boundary stays visible.
type PrismfyResult = {
title: string
url: string
content?: string
}
type PrismfyResponse = {
results: PrismfyResult[]
cached?: boolean
meta?: Record<string, unknown>
}
const PRISMFY_BASE_URL = process.env.PRISMFY_BASE_URL ?? "https://api.prismfy.io"
const PRISMFY_API_KEY = process.env.PRISMFY_API_KEY ?? ""
export async function prismfySearch(query: string, domain = "", timeRange = "week") {
const payload: Record<string, unknown> = { query, page: 1, timeRange }
if (domain) payload.domain = domain
const response = await fetch(`${PRISMFY_BASE_URL}/v1/search`, {
method: "POST",
headers: {
Authorization: `Bearer ${PRISMFY_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
})
if (!response.ok) {
throw new Error(`Prismfy search failed with ${response.status}`)
}
const data = (await response.json()) as PrismfyResponse
return {
cached: data.cached ?? false,
results: (data.results ?? []).slice(0, 4).map((item) => ({
title: item.title,
url: item.url,
snippet: (item.content ?? "").slice(0, 180),
})),
}
}
In your MCP server, the tool definition can call prismfySearch and return the small object it produces. The exact SDK boilerplate will vary by package version, but the retrieval contract stays the same.
If you want a simple input schema, keep it close to the API:
query for the user’s questiondomain when one source owns the truthtimeRange when recency mattersThat is enough for most live-evidence cases.
Keep the tool output short. MCP is a structured interface, but that does not mean you should pass the entire upstream payload through untouched. The model rarely needs everything. It needs enough evidence to answer or enough evidence to explain why it cannot.
Use domain when the answer should come from one public source. Use timeRange when the question is about current status or recent change. If the assistant asks for a broad web sweep, keep the result count low and be clear that the output is a shortlist, not an archive.
Prismfy is not doing the conversation for you. It is only the retrieval step. The assistant still decides whether the evidence is sufficient and how to phrase the answer.
That separation matters because it keeps the tool simple enough to maintain. The more logic you hide inside the search layer, the harder it becomes to debug source selection and answer quality.
If you want to make the tool safer, add a tiny validation step before the Prismfy call. For example, reject blank queries, trim excessive whitespace, and cap any optional domain input to one host. Those checks are boring, but they prevent your tool from turning malformed input into noisy results.
It also helps to keep a stable response schema for the MCP client. Even if Prismfy returns richer metadata later, your tool can continue returning a small object with query, cached, and a short results array. That makes downstream prompts and tests much easier to maintain.
Prismfy fits MCP because it keeps retrieval synchronous and visible. One call goes out, one result set comes back, and the tool can expose exactly the information the model needs.
That makes it practical for assistants that need fresh public facts without turning the server into a crawler or a browser controller. The tool stays narrow, the evidence stays inspectable, and the model stays grounded.
A retriever is useful for indexed material you control. A web search API helps when the question depends on fresh public evidence, new pages, current docs, or time-sensitive changes that may not exist in your retriever yet.
Keep the integration narrow: route only freshness-sensitive questions to Prismfy, pass a compact evidence set back to the framework, and ask the model to answer from sources instead of memory.
Create a Prismfy key, test POST /v1/search, and wire the search step into the workflow you care about first.
Try it free
Free tier includes 3,000 requests per 30 days. No credit card required.