OpenRouter LangChain MCP Server
Provides tools for querying MongoDB, including listing collections and running find queries with filters and limits.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@OpenRouter LangChain MCP ServerWhich users are active?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
OpenRouter LangChain MCP Server
A small command-line chatbot that lets an OpenRouter model query MongoDB through a Model Context Protocol (MCP) server.
The project has two processes:
server.jsexposes MongoDB query tools over MCP stdio transport.client.jsconnects to the server, binds its tools to a LangChain OpenRouter model, and provides an interactive chat prompt.
Requirements
Node.js 18 or newer
A running MongoDB instance
Related MCP server: mcp-mongo
Setup
Install dependencies:
npm installCreate a
.envfile in the project root:OPENROUTER_API_KEY=your_openrouter_api_key MONGODB_URI=mongodb://localhost:27017MONGODB_URIis optional and defaults tomongodb://localhost:27017.Start the interactive client:
npm start
The client starts server.js automatically over stdio, so the MCP server does not need to be started separately.
First run
The server uses the chatbot_db database. If both the users and orders collections are missing, it creates them and inserts sample records. Existing collections are left unchanged.
The sample data includes:
users: user IDs, names, email addresses, and statusesorders: order IDs, user IDs, products, and amounts
Available MCP tools
get_collections
Lists the collections in the configured MongoDB database.
query_collection
Runs a MongoDB find query. It accepts:
collection(required): collection name, such asusersorordersfilter(optional): MongoDB filter objectlimit(optional): maximum number of documents to return; defaults to10
Examples of questions to ask the chatbot:
Which users are active?
Show orders over $100.
What products did user 1 order?
List the available collections.Type exit to close the client.
Configuration
The client currently uses the OpenRouter model identifier:
nvidia/nemotron-3-ultra-550b-a55b:freeTo use another OpenRouter-supported model, change the model value in client.js.
Project structure
.
├── client.js # Interactive LangChain client
├── server.js # MCP server and MongoDB tools
├── package.json
└── README.mdNotes
Keep
.envout of version control because it contains your API key.The MCP server logs connection and seeding messages to stderr so they do not interfere with the stdio protocol.
The
npm startscript runsclient.js, which starts the MCP server automatically over stdio.
Chatbot

Users Collection

Orders Collection

Web application
The webapp/ directory contains a browser-based version of the chatbot. It
runs an Express server, serves the UI from webapp/public/index.html, and
exposes the chat endpoint at POST /api/chat.
The webapp runs the MCP server and client in the same Node.js process using an in-memory transport. The browser can therefore use the same MongoDB tools as the command-line client without starting a separate MCP process.
Run the webapp
Install the webapp dependencies:
cd webapp npm installCreate a
.envfile in thewebapp/directory:OPENROUTER_API_KEY=your_openrouter_api_key MONGODB_URI=mongodb://localhost:27017 PORT=3000MONGODB_URIdefaults tomongodb://localhost:27017, andPORTdefaults to3000.Start the server:
node server.jsOpen http://localhost:3000 in a browser.
Webapp behavior
The UI accepts natural-language questions about the MongoDB database.
Tool calls made by the model are displayed in the conversation.
The final model response is displayed after the tool calls complete.
Press
Enterto send a message, or use the Send button.The API returns
{ reply, steps }for successful requests and{ error }for failures.
Example request:
curl -X POST http://localhost:3000/api/chat \
-H "Content-Type: application/json" \
-d '{"message":"Show me active users"}'Webapp project structure
webapp/
├── public/
│ └── index.html # Browser chat interface
├── package.json
└── server.js # Express app, MCP tools, and chat APIThe webapp uses the same chatbot_db database and sample users and
orders collections described above. Keep the .env file out of version
control because it contains the OpenRouter API key.
Webapp

This server cannot be deployed
Maintenance
Related MCP Connectors
The OpenRouter for tools. One MCP connection gives any AI agent 254 hosted tools, pay per call.
The OpenRouter MCP server plugs OpenRouter into the AI tools you already use. Once connected, your assistant can pull live OpenRouter data (models, prices, your credits, rankings, and docs) and send quick test messages, all without leaving your editor.
OpenRouter for tools and data. Compare catalog providers and call them from one hosted MCP endpoint.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceA Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.28 npm175MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to query and introspect MongoDB databases through find, aggregate, and schema discovery operations. Supports read-only default mode with optional write capabilities and works with any MCP-compatible client via stdio or HTTP transports.-
- AlicenseNot gradedqualityDmaintenanceEnables CRUD operations on MongoDB databases and collections, including listing databases and collections, via MCP tools.12 npmApache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with MongoDB databases through natural language, supporting document CRUD, aggregation, collection listing, and statistics.139,525 npmApache 2.0