Install mcp-searxng and Connect with Localtonet
Install mcp-searxng with npm, enable its Streamable HTTP server, verify the local MCP endpoint, and connect remotely with Localtonet.
In this article 9 sections
Build, authenticate, test, and publish a SearXNG-backed MCP endpoint
mcp-searxng connects MCP-compatible AI applications to an existing SearXNG search service. This guide installs the executable with npm, records the installed version, validates SearXNG's JSON API, enables Streamable HTTP, adds static bearer authentication, and verifies the complete workflow with MCP Inspector. Only after those local checks pass do we create a Localtonet HTTP tunnel and repeat both unauthorized and authorized tests through the public endpoint.
📋 What's in this guide
Understand the mcp-searxng architecture
mcp-searxng is an MCP server that gives compatible AI clients access to web search and URL-reading tools. It does not provide a search index and does not install SearXNG. Instead, it sends search requests to a separately running SearXNG instance whose JSON response format is enabled.
A remote search crosses several independent boundaries. The MCP client initializes a protocol session with mcp-searxng, discovers its tools, and invokes a search tool. mcp-searxng then calls the configured SearXNG search API. When remote access is enabled, Localtonet carries the HTTP exchange from the public address to the local mcp-searxng listener.
SEARXNG_URL.
Do not confuse the SearXNG URL with the MCP URL. SEARXNG_URL points from mcp-searxng to the search service. The URL ending in /mcp points from an MCP client to mcp-searxng.
| Value | Used by | Purpose |
|---|---|---|
https://search.example.com |
mcp-searxng | Illustrative SearXNG base URL supplied through SEARXNG_URL. |
http://127.0.0.1:8080/mcp |
Local MCP client | Local Streamable HTTP endpoint used in this tutorial. |
Localtonet public URL plus /mcp |
Remote MCP client | Authorized public route through the tunnel to the local MCP service. |
| Bearer token | mcp-searxng and approved clients | Application-level credential sent in the HTTP Authorization header. |
STDIO and Streamable HTTP are different transports
mcp-searxng uses STDIO by default when MCP_HTTP_PORT is not set. In STDIO mode, an MCP client starts the executable as a child process and exchanges messages through standard input and output. This is useful when the client and server run on the same computer, but it does not create a listening network port.
A Localtonet HTTP tunnel needs a local HTTP service identified by an IP address and port. The tunnel does not convert STDIO into HTTP. For this workflow, mcp-searxng must run in its documented Streamable HTTP mode, listen on a local port, and pass MCP initialization and tool-call tests before tunneling begins.
Validate the SearXNG JSON API first. Then validate the local MCP listener, authentication, initialization, tool discovery, and a real search. Add Localtonet only after every local checkpoint succeeds. This sequence prevents a SearXNG or MCP configuration error from being misdiagnosed as a tunnel problem.
Prepare Node.js, SearXNG, and the test client
This tutorial uses the globally installed npm executable and MCP Inspector. Prepare the following components:
- Node.js 22 or later: The project requires Node.js 22 or later for the npm and NPX installation paths described here.
- npm and npx: npm installs mcp-searxng, while npx starts MCP Inspector.
- An existing SearXNG instance: mcp-searxng does not install or operate SearXNG for you.
- SearXNG JSON output: The
jsonresponse format must be enabled in the SearXNG configuration. - The Localtonet client: Install and run it on the same machine as mcp-searxng for the loopback setup used here.
- A securely stored bearer token: Use a strong secret created and managed according to your organization's credential policy.
Check Node.js and npm
node --version
npm --version
npx --version
The Node.js result must report major version 22 or later. If Node.js is missing or older, install a supported release before continuing. Installation differs by operating system and package manager, so use the method approved for your environment.
Enable the SearXNG JSON response format
SearXNG controls API response formats in its settings.yml configuration. Under the search section, make sure json is included in the enabled formats. Preserve any formats your deployment already needs.
search:
formats:
- html
- json
Restart or reload SearXNG using the procedure appropriate for your deployment after changing its configuration. The file location and restart mechanism depend on how SearXNG was installed, such as a container, system service, or another managed environment.
The official SearXNG search API documentation explains the /search endpoint, query parameters, and supported output formats.
Test the SearXNG JSON API independently
Replace the placeholder host with the SearXNG base URL you operate or trust. Test the search API before starting mcp-searxng:
curl --fail-with-body --silent --show-error \
--get "https://search.example.com/search" \
--data-urlencode "q=SearXNG" \
--data "format=json"
On Windows, use curl.exe if PowerShell maps curl to another command. A successful response should be JSON rather than an HTML search page. It should contain the normal SearXNG response structure and search results or an empty result set, depending on the configured engines and query.
If the server returns HTTP 403 for format=json, an HTML document, or a response saying the format is unavailable, correct the SearXNG configuration before proceeding. If the request cannot connect, repair the SearXNG listener, URL, DNS, certificate, proxy, or network path first.
A SearXNG operator can receive submitted queries and may log them. Running your own instance can reduce reliance on an external operator, but SearXNG and this MCP integration do not provide anonymity by themselves. Use an instance that you operate or explicitly trust.
Review the primary project documentation
mcp-searxng changes independently from this article. Before installation, compare the commands and settings below with the project's current README and configuration reference. The published package is available on the mcp-searxng npm page, and version-specific changes appear in the project release notes.
Install mcp-searxng and record the installed version
The unqualified npm command installs the version currently selected by the package's npm distribution tag. That version may be newer than releases discussed in this article. Record what npm actually installs instead of assuming that it is v2.6.0 or any other release.
Confirm Node.js 22 or later
Run the version checks above and resolve any runtime problem before installing the package.
Install the global executable
Install the published mcp-searxng package globally with npm.
Locate the command and record its version
Confirm that the executable is on the current PATH, then use npm's global package inventory to record the exact installed package version.
npm install -g mcp-searxng
npm list -g mcp-searxng --depth=0
The second command prints an entry such as mcp-searxng@x.y.z. Record that complete version in your deployment notes. Do not replace it with a version copied from this article.
On macOS or Linux, confirm that the shell can locate the executable:
command -v mcp-searxng
In PowerShell, use:
Get-Command mcp-searxng
npm list -g mcp-searxng --depth=0
A successful command lookup proves only that the executable is available. It does not start the server or test SearXNG.
Pin a version when repeatability matters
If your deployment requires a reproducible package version, install the reviewed release explicitly by appending @version to the package name. Replace the placeholder with a real release selected from the npm package page and release notes:
npm install -g mcp-searxng@<reviewed-version>
npm list -g mcp-searxng --depth=0
The placeholder is intentional and must not be copied unchanged. Pinning prevents a later npm distribution-tag change from silently selecting a different release during another installation.
Supported executable installation paths
The project also documents NPX, a pre-built Docker image, a locally built Docker image, and Docker Compose. The pre-built container includes its own Node.js runtime. This tutorial stays with the globally installed executable so that host binding, environment values, process ownership, and the Localtonet target remain easy to inspect.
The documented integration is the executable MCP server through CLI, NPX, or a container. JavaScript and TypeScript package imports were still described as unsupported in the v2.6.0 release notes.
Configure Streamable HTTP and static bearer authentication
The local server needs a SearXNG URL, an HTTP host, an HTTP port, and a bearer credential. The current project configuration reference documents MCP_HTTP_BEARER_TOKEN for static bearer protection. Confirm that this setting is present in the configuration reference for the exact package version recorded during installation.
This tutorial binds mcp-searxng to 127.0.0.1 on port 8080. The resulting endpoint is http://127.0.0.1:8080/mcp. Loopback binding prevents direct access from other machines while allowing a Localtonet client on the same computer to reach the service.
Project configuration is version-sensitive. If the installed release does not document MCP_HTTP_BEARER_TOKEN, or if its authentication instructions differ from this workflow, stop here and follow the configuration reference for that exact release. Do not start a public tunnel to an unauthenticated MCP endpoint.
Set the environment on macOS or Linux
Create a strong secret using your approved credential-management process. Enter it locally in place of the placeholder. Do not publish the resulting value:
export SEARXNG_URL="https://search.example.com"
export MCP_HTTP_HOST="127.0.0.1"
export MCP_HTTP_PORT="8080"
export MCP_HTTP_BEARER_TOKEN="REPLACE_WITH_A_STRONG_SECRET"
mcp-searxng
Set the environment in PowerShell
$env:SEARXNG_URL = "https://search.example.com"
$env:MCP_HTTP_HOST = "127.0.0.1"
$env:MCP_HTTP_PORT = "8080"
$env:MCP_HTTP_BEARER_TOKEN = "REPLACE_WITH_A_STRONG_SECRET"
mcp-searxng
Keep the process running while testing. Review its output for an invalid SearXNG URL, an occupied port, unsupported configuration, or another startup failure. Log wording can change between releases, so a startup message is not sufficient proof of readiness.
The placeholder is not a usable secret. Replace it locally with a strong value, keep it out of screenshots and repositories, and avoid storing it in shared shell history or logs. For a long-running service, provide it through the secret-management mechanism supported by your operating system, container platform, or process manager. Rotate it if it is exposed.
Confirm that the port is listening
On macOS or Linux:
lsof -nP -iTCP:8080 -sTCP:LISTEN
On Windows:
Get-NetTCPConnection -LocalPort 8080 -State Listen
If no listener appears, inspect the mcp-searxng process before testing authentication. Confirm that the HTTP variables were set in the same environment from which the executable was started.
Verify that an unauthenticated request is rejected
Before configuring any MCP client, send a request without an Authorization header:
curl -i http://127.0.0.1:8080/mcp
The important result is an authentication rejection, normally an HTTP 401 response for a bearer-protected endpoint. Do not continue if the request is accepted without credentials. A protocol-specific response such as a method or initialization error is not equivalent to an authentication rejection.
If the request is not rejected at the authentication boundary, stop the server and compare your installed version with the mcp-searxng configuration reference. Resolve that discrepancy while the service remains local-only.
Verify initialization, tools, and search with MCP Inspector
MCP Inspector provides a concrete Streamable HTTP test client. It is more useful than opening /mcp in a browser because it can initialize the MCP connection, discover tools, and invoke a real tool.
Start MCP Inspector
Open a second terminal while mcp-searxng remains running:
npx @modelcontextprotocol/inspector
npm may ask permission to download the Inspector package on first use. Record the package version selected by npm if the test must be repeated later under identical conditions. Follow the local address printed by Inspector to open its interface.
Configure the Streamable HTTP connection
- Select Streamable HTTP as the transport.
- Enter
http://127.0.0.1:8080/mcpas the server URL. - Add an HTTP header named
Authorization. - Set its value to
Bearer YOUR_LOCAL_TOKEN, replacing the placeholder with the same secret supplied to mcp-searxng. - Connect and allow Inspector to initialize the MCP session.
Do not paste the credential into screenshots, tickets, or public logs. If Inspector is running on a shared machine, clear the header after testing and follow your local credential-handling policy.
Confirm initialization and discover tools
A successful connection proves that the server accepted the bearer credential and completed MCP initialization. Open the Inspector tools view and request the server's tool list.
Tool names are version-sensitive. The project documentation has described tools including:
searxng_web_searchfor web searches, pagination, filters, and supported output formats.searxng_search_suggestionsfor query suggestions.searxng_instance_infofor instance capabilities such as categories and engines.web_url_readfor reading a known URL as text or Markdown.
Compare the actual tool inventory with the README for the installed package version. A missing or renamed tool may indicate a version difference rather than a transport failure.
Invoke a real search
Select the search tool shown by the installed server. When the tool is named searxng_web_search, use this minimal input:
{
"query": "SearXNG"
}
Run the tool and inspect the result. This verifies the complete local path from Inspector to the authenticated mcp-searxng endpoint and then to the configured SearXNG instance.
Tool discovery alone is not enough. Discovery can succeed even when SEARXNG_URL is wrong or the JSON search interface is unavailable. A completed search invocation is the required local readiness checkpoint.
Record the mcp-searxng package version, Inspector version, SearXNG base URL without credentials, local endpoint, discovered search-tool name, and test time. Never record the bearer value itself. This makes later updates and regressions easier to compare.
Test an incorrect credential
Change the Inspector header temporarily to a deliberately incorrect value and reconnect. Initialization must fail with an authorization response. Restore the correct token and confirm that initialization, tool discovery, and the search invocation succeed again.
At this point you have demonstrated all three required local outcomes:
- A request without credentials is rejected.
- A client with an incorrect credential is rejected.
- A client with the correct credential initializes, discovers tools, and completes a real search.
Connect the authenticated service with Localtonet
Create the tunnel only after every local authentication and search test has passed. Our client establishes an outbound connection to a Localtonet relay server, so the normal workflow does not require inbound router port forwarding, a public IP address, VPN setup, or a new inbound firewall listener.
The tunnel target is the local HTTP service at 127.0.0.1 and port 8080. The /mcp route is part of the application URL, not the local port field. If the dashboard assigns a public base URL, append /mcp when configuring the MCP client.
Install and run the Localtonet client
Run our client on the same computer as mcp-searxng. A service bound to 127.0.0.1 can only be reached by software on that computer.
Authenticate or select the client device
Use the supported client workflow with the device-specific authentication token, then select the connected device that will run the tunnel. Do not publish the token or reuse one that has been exposed.
Select an available relay server
Choose a currently available server or region from the dashboard. Obtain available values from the product instead of copying a hardcoded server code.
Create the HTTP tunnel
Select an HTTP tunnel and set the local target to IP address 127.0.0.1 and port 8080. For Process Type, select Random Sub Domain, Custom Sub Domain, or Custom Domain from the options available to your account and plan.
Start the tunnel
Creating the configuration does not start it. Use the Start button, wait for the selected client and tunnel to connect, and copy the public HTTPS URL displayed by the dashboard.
Retest authentication and MCP behavior
Append /mcp to the assigned public URL. Verify that unauthenticated access is rejected, then connect an authorized MCP client and repeat initialization, tool discovery, and the real search invocation.
The three Process Type choices serve the same content at a public HTTPS address, but availability can vary by account, plan, or current product configuration. Use only the options presented in your dashboard. For the current setup flow, consult our Localtonet HTTP tunnel documentation.
Verify rejection through the public address
Replace the example with the exact public address assigned to the running tunnel:
curl -i https://assigned-public-host.example/mcp
The public request without an authorization header must be rejected just as the local request was. If it is accepted, stop the tunnel immediately and investigate the mcp-searxng authentication configuration. Do not rely on the public URL being difficult to guess.
Verify an authorized public MCP connection
In MCP Inspector, change the Streamable HTTP URL to the exact public HTTPS URL ending in /mcp. Keep the Authorization header in this form:
Authorization: Bearer YOUR_LOCAL_TOKEN
Connect, confirm initialization, open the tools list, and run the same search query used locally. This tests the remote client, bearer authentication, public URL, Localtonet tunnel, local mcp-searxng process, and SearXNG service together.
Localtonet transports requests to the selected local service. mcp-searxng remains responsible for its application-level authentication. Share the endpoint and credential only with intended clients, rotate exposed credentials, and stop the tunnel when public access is no longer required.
Operate, update, and retire the deployment safely
Keep both required processes running
Remote access depends on mcp-searxng and the selected Localtonet client. If mcp-searxng stops, the tunnel has no working local service to reach. If the Localtonet client disconnects or the tunnel is stopped, the public route becomes unavailable even if mcp-searxng remains healthy.
A terminal session is suitable for initial testing. For longer operation, use an operating-system or container process manager approved for your environment. Ensure that it supplies the required environment values without printing the bearer token into shared logs.
Separate current behavior from v2.6.0 details
Transport, authentication, tool names, and session handling can change between releases. Always treat the README and configuration reference associated with the installed version as authoritative.
The following limits are specifically documented for mcp-searxng v2.6.0. They must not be assumed for a different installed release:
- Retained stateful HTTP sessions allow 16 POST requests per session by default.
- They allow 4 standalone GET streams per session by default.
- The documented process-wide defaults are 256 for each category.
- Excess work returns HTTP 503 with
Retry-After: 1. - DELETE remains available when those concurrency limits are reached.
- Initialization shares the POST pool with reserved headroom for established sessions.
Version 2.6.0 documents four MCP_HTTP_MAX_* settings for tuning these controls. Use the exact names and guidance in the configuration reference for the installed release instead of guessing values.
Understand version-specific session behavior
The project distinguishes modern HTTP requests, legacy stateless HTTP, and retained stateful legacy sessions. The behavior of these modes should be confirmed against the installed release.
For the retained stateful behavior documented around v2.6.0, a client should terminate a finished session appropriately. A later request for a terminated session can receive HTTP 404, after which the client should initialize a new session. Compatible MCP clients normally manage this lifecycle without manual HTTP commands.
Update deliberately
Before updating, record the working package version and review the mcp-searxng release notes. After installing an update, record the new version and repeat the entire verification sequence:
- Test the SearXNG JSON API directly.
- Start mcp-searxng with the expected configuration.
- Confirm that unauthenticated local access is rejected.
- Initialize through MCP Inspector with the correct credential.
- Discover tools and complete a real search.
- Start the Localtonet tunnel.
- Confirm public rejection without a credential.
- Repeat the authorized search through the public endpoint.
Stop access cleanly
Disconnect MCP clients cleanly when possible, stop the Localtonet tunnel, and then stop mcp-searxng. Delete the tunnel if its configuration is no longer needed. Stopping the tunnel removes public reachability but does not stop the local process.
Clearing a shell variable after testing can reduce accidental reuse in that shell, although it does not replace proper secret management. Rotate the bearer token whenever its confidentiality is uncertain.
Troubleshoot installation, authentication, and tunnel failures
| Symptom | Likely layer | What to check |
|---|---|---|
| npm rejects the runtime | Node.js | Confirm that node --version reports Node.js 22 or later. |
mcp-searxng is not found |
Global npm PATH | Confirm installation and verify that npm's global executable directory is on the current user's PATH. |
| SearXNG returns HTML or HTTP 403 for JSON | SearXNG configuration | Confirm that json appears under search.formats and that SearXNG was reloaded. |
| No listener appears on port 8080 | mcp-searxng startup | Check MCP_HTTP_PORT, startup output, port conflicts, and the environment inherited by the process. |
| An unauthenticated request is accepted | Authentication configuration | Stop public exposure and verify the bearer setting against the configuration reference for the installed version. |
| Inspector receives HTTP 401 | Credential handling | Use the Authorization header with Bearer followed by the exact configured token. |
| Inspector cannot initialize | Transport or endpoint | Select Streamable HTTP and use the complete URL ending in /mcp. |
| Tools appear but searches fail | SearXNG path | Retest the JSON API directly and check SEARXNG_URL, connectivity, and SearXNG errors. |
| Local MCP works but the public URL fails | Localtonet lifecycle | Confirm that our client is connected, the tunnel is started, and the target is 127.0.0.1:8080. |
| The public host responds but MCP does not | Application route | Append /mcp to the exact HTTPS base URL assigned by Localtonet. |
| HTTP 404 follows a terminated retained session | Session lifecycle | Initialize a new session and verify behavior against the installed release documentation. |
HTTP 503 with Retry-After: 1 |
mcp-searxng concurrency | For versions with the documented controls, retry as directed and review retained sessions and the applicable MCP_HTTP_MAX_* settings. |
The direct SearXNG check succeeds but MCP searches fail
Confirm that SEARXNG_URL contains the expected base URL and was present when mcp-searxng started. A variable added after process startup does not change the running process. Also check whether the service account has the same DNS, proxy, and certificate access as the account used for the successful curl test.
The command works interactively but not under a process manager
Service managers often use a different PATH and environment from an interactive shell. Confirm that the service account can locate the global executable and receives SEARXNG_URL, MCP_HTTP_HOST, MCP_HTTP_PORT, and the documented authentication setting.
Port 8080 is already in use
Stop the conflicting program or choose another available local port. Update MCP_HTTP_PORT, the Inspector URL, and the Localtonet target together. The endpoint path remains /mcp.
The Localtonet client runs on another machine
Another machine cannot connect to 127.0.0.1 on the mcp-searxng host. The safest arrangement for this tutorial is to run our client and mcp-searxng on the same computer. Using a non-loopback listener requires deliberate LAN reachability, firewall review, and access-control planning.
The remote application only supports STDIO
A command-based STDIO configuration cannot consume the tunneled HTTPS endpoint unless the client also supports a remote Streamable HTTP connection. Check the client's transport documentation. Do not place a public URL into a field that expects a local command and arguments.
A browser displays an error at the MCP URL
Streamable HTTP is an MCP transport, not an ordinary website. A browser navigation does not perform the required initialization and may produce a method, session, authorization, or protocol error. Use MCP Inspector or another compatible Streamable HTTP client for the functional test.
Frequently asked questions
Does mcp-searxng install SearXNG?
No. mcp-searxng connects to an existing SearXNG deployment. You must provide its base URL and enable the JSON response format in SearXNG.
How do I verify that SearXNG is ready?
Send a direct request to /search with a query and format=json. Resolve HTML responses, HTTP 403 errors, connectivity failures, or malformed output before starting mcp-searxng.
Why can’t I tunnel the default STDIO mode?
STDIO exchanges protocol messages through a child process's standard input and output. It does not open an HTTP port. A Localtonet HTTP tunnel needs a reachable local IP address and port, so mcp-searxng must first run in Streamable HTTP mode.
What is the local MCP URL in this tutorial?
With the host set to 127.0.0.1 and the port set to 8080, the complete endpoint is http://127.0.0.1:8080/mcp.
How should an MCP client send the bearer credential?
Configure an HTTP header named Authorization whose value is Bearer followed by the secret configured for mcp-searxng. Keep the credential out of public examples, screenshots, and repositories.
Does successful tool discovery prove that search works?
No. Discovery proves that the MCP client can communicate with mcp-searxng. Invoke the installed search tool with a real query to verify connectivity from mcp-searxng to SearXNG.
What URL should a remote MCP client use?
Use the public HTTPS base address assigned to the running Localtonet HTTP tunnel and append /mcp. Copy the address from the dashboard rather than guessing it.
Is the public Localtonet URL an authentication mechanism?
No. The URL identifies the endpoint. Configure mcp-searxng authentication, prove that unauthenticated access is rejected, and verify an authorized client before sharing public access.
Must the Localtonet client run on the same computer?
It must run on the same computer for a target bound to 127.0.0.1. Our client can target another reachable device, but that requires a non-loopback listener and deliberate network-security configuration.
Do the v2.6.0 concurrency defaults apply to every version?
No. The limits described in this guide are explicitly tied to the v2.6.0 release notes. Check the documentation and release notes for the exact version reported by npm list -g mcp-searxng --depth=0.
Will the public endpoint work after mcp-searxng stops?
No. The tunnel may remain connected, but it will have no working local HTTP service to forward requests to. Remote access requires mcp-searxng, the Localtonet client, and the tunnel to remain active.
Connect your authenticated MCP endpoint with Localtonet
After SearXNG returns JSON, mcp-searxng rejects unauthorized requests, and MCP Inspector completes an authorized search locally, create an HTTP tunnel to 127.0.0.1:8080 and repeat the same rejection and authorized-access tests through the assigned HTTPS endpoint.
Corrections & updates
Substantive changes approved by the Localtonet editorial team are listed transparently below.
Localtonet is a secure multi-protocol tunneling and proxy platform designed to expose localhost, devices, private services, and AI agents to the public internet supporting HTTP/HTTPS tunnels, TCP/UDP forwarding, mobile proxy infrastructure, file server publishing, latency-optimized game connectivity, and developer-ready AI agent endpoint exposure from a single unified control plane.