MCP Integration
Node.js AI SDK Integration
Node.js developers can connect directly to the SearchMCP MCP server using libraries like @ai-sdk/mcp
or the mcp-remote
CLI. This enables real-time Google search inside your custom agents or LLM applications.
Install dependencies
First, add the MCP client library to your Node.js project:
pnpm add @ai-sdk/mcp
# or
npm install @ai-sdk/mcp
# or
yarn add @ai-sdk/mcp
Connect with
@ai-sdk/mcp
Use the @ai-sdk/mcp
client to establish a connection to SearchMCP. Add your x-api-key
header for authentication:
import { connect } from "@ai-sdk/mcp";
const client = await connect({
url: "https://api.searchmcp.io/mcp",
headers: {
"x-api-key": "smcp_<YOUR_API_KEY>"
}
});
// List available tools
const tools = await client.listTools();
console.log(tools);
// Call the search tool
const result = await client.callTool("google_web_search", {
query: "apple inc",
numberOfResults: 5,
});
console.log(result);
Replace <YOUR_API_KEY>
with your key from Dashboard → API Keys.
Alternative: mcp-remote CLI
You can also use mcp-remote
in Node.js scripts to proxy requests to the SearchMCP server:
npx mcp-remote https://api.searchmcp.io/mcp --header "x-api-key: smcp_<YOUR_API_KEY>"
Next steps
- See MCP Overview for endpoints & schemas
- Integrate with LangChain or other frameworks
- Call the REST Search API directly if you don’t need MCP