Skip to main content
Glama

Ollama MCP Server

by hyzhak
systemPatterns.md1.7 kB
# System Patterns ## Architecture Overview - **Functional MCP Server**: The main logic is implemented in a functional style using `McpServer` from `@modelcontextprotocol/sdk`. - **Tool Registration**: Each Ollama operation (list, show, create, pull, push, cp, rm, run, chat_completion) is registered as an MCP tool using `registerTool`. - **Input Validation**: Uses Zod schemas for runtime and static validation of tool arguments. - **Transport Support**: Currently supports stdio transport for CLI/stdio integration. HTTP/SSE transport is planned for future releases. - **Ollama Integration**: Uses `ollama-js` for all interactions with the Ollama API. ## Key Technical Decisions - **registerTool Pattern**: All MCP tools are registered with explicit input schemas and async handler functions. - **Type Safety**: Handlers are fully type-safe, leveraging TypeScript and Zod. - **Error Handling**: Errors are caught and formatted for MCP compatibility. - **Streaming Output**: Streaming is not supported in stdio MCP transport; the "run" tool returns the full response only after completion. Future HTTP/SSE transport may enable true streaming support. ## Component Relationships - `McpServer` manages tool registration and transport setup. - Each tool handler translates MCP requests to Ollama API calls using `ollama-js`. - Zod schemas define and validate the structure of tool arguments. ## Critical Implementation Paths - MCP request → tool handler (via registerTool) → Ollama API (via ollama-js) → result mapped to MCP response. - Chat completion tool adapts OpenAI-style messages to Ollama prompt format. - Server startup initializes stdio transport; HTTP/SSE is a future enhancement.

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/hyzhak/ollama-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server