MCP Server Ollama
Provides tools for managing posts and comments stored in MongoDB, including creating, reading, updating, and deleting posts, as well as adding and listing comments.
Integrates with Ollama to understand user intent and generate JSON-RPC 2.0 requests for MCP tools, enabling natural language interaction with the backend.
Click on "Install 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., "@MCP Server OllamaCreate a blog post about the future of AI"
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.
MCP Server Ollama - Decoupled Architecture
This repository contains a small blog-style application with two working flows, both using decoupled architecture with JSON-RPC:
AI Chatbot Flow (recommended for production): Natural language requests are converted to JSON-RPC by the AI, then executed through the MCP protocol.
MCP Client Flow: An MCP-compatible client directly calls the MCP endpoint with JSON-RPC requests.
The project is split into two services:
Main REST API server: server.js
MCP server with Ollama integration: mcp-server/server.js
What the app does
The main API stores and manages posts and comments in MongoDB.
Posts contain: title, author, category, body, createdAt
Comments belong to a post and contain: postId, text, commenter, createdAt
The MCP server adds two higher-level interaction paths on top of that REST API.
Related MCP server: @damusix/buffer-mcp
Architecture: Decoupled via JSON-RPC
Flow 1: AI Chatbot -> JSON-RPC -> MCP -> REST API -> MongoDB
This is the decoupled, production-recommended flow used when a user talks to the chatbot interface or sends a request to the AI endpoint.
Why this architecture?
AI Layer (Ollama): Focuses ONLY on understanding user intent and generating JSON-RPC requests. Does NOT know about backend details.
MCP Layer: Acts as middleware to execute JSON-RPC requests using the standard MCP protocol.
Backend Layer: REST API and database remain isolated from AI logic.
Flow Steps:
A user sends a message such as "Create a new post..." to the chatbot UI or to the
/ai-chatbotendpoint.The MCP server sends the message to Ollama.
Ollama understands the intent and generates a JSON-RPC 2.0 request to call the appropriate MCP tool (e.g.,
create_post).The MCP client executes that JSON-RPC request through the MCP protocol.
The appropriate MCP tool is invoked, which calls the REST API.
The REST API updates MongoDB and returns the result.
Separation of Concerns:
User Message
↓
[AI Layer] Ollama
→ Understands intent
→ Generates JSON-RPC request
↓
[MCP Layer] MCP Client
→ Sends JSON-RPC to MCP Server
→ Executes tool
↓
[Backend Layer] REST API
→ MongoDBThis path is used by:
the chatbot page at
public/chatbot.htmlthe endpoint
POST /ai-chatboton the MCP server
Flow 2: MCP Client -> /mcp -> MCP Tools -> REST API -> MongoDB
This flow is used when an MCP-compatible client connects to the MCP server directly.
The MCP client sends a JSON-RPC request to
POST /mcp.The MCP server handles initialization and tool calls.
The server invokes registered tools such as create_post, list_posts, update_post, delete_post, add_comment, and list_comments.
Each tool calls the main REST API.
The REST API performs the action in MongoDB.
This is the path used by MCP-compatible clients.
Key Differences: Tight Coupling vs. Decoupled
Aspect | Before (Tight Coupling) | After (Decoupled) |
AI Responsibility | Directly calls REST API endpoints | Only understands intent, generates JSON-RPC |
Coupling | AI tightly bound to backend structure | AI and backend completely decoupled |
Protocol | Direct HTTP calls | Standard JSON-RPC 2.0 protocol |
Middleware | None | MCP layer acts as middleware |
Scalability | Difficult to replace AI or backend | Easy to swap AI model or backend service |
Production Ready | Not recommended ❌ | ✓ Production-ready ✓ |
Standard Compliance | Proprietary | JSON-RPC 2.0 + MCP Standard |
How JSON-RPC Decoupling Works
Example: User says "Create a tech post about AI"
Step 1: AI generates JSON-RPC request (not direct execution)
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "create_post",
"arguments": {
"title": "Understanding AI",
"author": "John Doe",
"category": "tech",
"body": "Artificial Intelligence is transforming how we work and live..."
}
},
"id": 1
}Key Point: Ollama ONLY generates this JSON-RPC request. It does NOT execute it directly.
Step 2: MCP Client sends this JSON-RPC to MCP Server
The MCP client (in the MCP server itself) sends this JSON-RPC request to the /mcp endpoint.
Step 3: MCP Server executes the tool
The MCP server routes the create_post tool call, which validates the input and calls the REST API.
Step 4: REST API persists to MongoDB
POST /posts → Validation → MongoDB.insert() → Returns created postStep 5: Result flows back
MCP Server → MCP Client → Chatbot UI → User sees the created postBenefits of This Architecture
1. Loose Coupling
You can independently:
Replace Ollama with another AI model (GPT, Claude, etc.) without changing backend
Switch backend from REST API to gRPC without changing AI
Deploy AI and backend in different regions or cloud providers
Use different programming languages for each layer
2. Scalability
Load balance MCP layer independently from AI and backend
Cache AI responses without affecting backend performance
Implement retry logic and circuit breakers at MCP level
Scale AI horizontally without scaling backend
3. Testability
AI layer testable independently (mock MCP)
MCP layer testable independently (mock REST API)
Backend testable independently (mock MCP layer)
Clear unit test boundaries
4. Standards Compliance
Uses standard JSON-RPC 2.0 protocol (not proprietary)
Compatible with any MCP-compliant client
Follows Model Context Protocol specification
Can integrate with other MCP servers
5. Production Ready
Proper separation of concerns
Clear error boundaries and logging
Middleware pattern enables monitoring at MCP level
Request tracing across layers
No tight coupling risks
6. Maintainability
Changes to backend don't affect AI logic
Updates to AI model don't require backend changes
Clear interfaces between layers (JSON-RPC)
Easier debugging with layer isolation
Available MCP Tools
The MCP server exposes the following tools:
create_post:
{title, author, category, body}- Creates a new postlist_posts:
{}- Lists all postsget_post:
{postId}- Gets a single post by IDupdate_post:
{postId, title, author, category, body}- Updates an existing postdelete_post:
{postId}- Deletes a post (WARNING: deletes post and ALL comments)add_comment:
{postId, text, commenter}- Adds a comment to a postlist_comments:
{postId}- Lists all comments for a post
Implementation Details
AI Layer (processUserMessage)
Receives user message and context
Sends to Ollama with system prompt focused on intent understanding
Ollama generates a JSON-RPC 2.0 request (not action plan)
Returns JSON-RPC request WITHOUT executing it
MCP Layer (executeMcpToolViaJsonRpc)
Receives JSON-RPC request from AI layer
Validates tool name and arguments
Executes appropriate tool logic
Returns JSON-RPC 2.0 response
Backend Layer (/posts endpoints)
Handles REST API requests from MCP layer
Performs MongoDB operations
Returns results to MCP layer
Endpoints
POST /ai-chatbot: Accepts user message, returns AI-generated JSON-RPC + execution result
POST /mcp: Standard MCP protocol endpoint for MCP clients
GET /health: Health check endpoint
Response Format from /ai-chatbot
{
"success": true,
"jsonRpcRequest": {
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "create_post",
"arguments": {...}
},
"id": 1
},
"jsonRpcResponse": {
"jsonrpc": "2.0",
"result": {...},
"id": 1
},
"executionTime": "245ms"
}This response shows:
The JSON-RPC request AI generated
The JSON-RPC response from tool execution
Execution time for monitoring
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/varun123936/mcp-server-ollama1'
If you have feedback or need assistance with the MCP directory API, please join our Discord server