Skip to main content
Glama

mcp_ollama_chat_completion

Generate responses using an OpenAI-compatible chat completion API with Ollama models, supported by Ontology MCP for integrating AI with ontology data queries.

Instructions

OpenAI 호환 채팅 완성 API를 사용하여 응답을 생성합니다

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messagesYes대화 메시지 배열
modelYes사용할 Ollama 모델 이름
temperatureNo샘플링 온도(0-2)
timeoutNo타임아웃(밀리초 단위, 기본값: 60000)

Implementation Reference

  • MCP tool handler that delegates to ollamaService.chatCompletion and wraps result in ToolResponse format.
    async handler(args: any): Promise<ToolResponse> {
      const result = await ollamaService.chatCompletion(args);
      return {
        content: [
          {
            type: 'text' as const,
            text: result
          }
        ]
      };
    }
  • Input schema defining parameters for the mcp_ollama_chat_completion tool: model, messages, temperature, timeout.
    inputSchema: {
      type: 'object',
      properties: {
        model: {
          type: 'string',
          description: '사용할 Ollama 모델 이름'
        },
        messages: {
          type: 'array',
          items: {
            type: 'object',
            properties: {
              role: {
                type: 'string',
                enum: ['system', 'user', 'assistant']
              },
              content: {
                type: 'string'
              }
            },
            required: ['role', 'content']
          },
          description: '대화 메시지 배열'
        },
        temperature: {
          type: 'number',
          description: '샘플링 온도(0-2)',
          minimum: 0,
          maximum: 2
        },
        timeout: {
          type: 'number',
          description: '타임아웃(밀리초 단위, 기본값: 60000)',
          minimum: 1000
        }
      },
      required: ['model', 'messages']
    },
  • Core OllamaService.chatCompletion method: POST to /api/chat endpoint, formats response as OpenAI-compatible chat completion JSON.
    async chatCompletion(args: {
      model: string;
      messages: Array<{ role: string; content: string }>;
      temperature?: number;
      timeout?: number;
    }): Promise<string> {
      try {
        // 최신 Ollama API는 채팅 메시지 형식을 직접 지원
        const response = await axios.post<OllamaChatResponse>(
          this.getApiUrl('chat'),
          {
            model: args.model,
            messages: args.messages,
            stream: false,
            temperature: args.temperature,
          },
          {
            timeout: args.timeout || DEFAULT_TIMEOUT,
          }
        );
    
        // OpenAI 호환 형식으로 응답 포맷팅
        return JSON.stringify({
          id: 'chatcmpl-' + Date.now(),
          object: 'chat.completion',
          created: Math.floor(Date.now() / 1000),
          model: args.model,
          choices: [
            {
              index: 0,
              message: {
                role: 'assistant',
                content: response.data.message.content,
              },
              finish_reason: 'stop',
            },
          ],
        }, null, 2);
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new McpError(
            ErrorCode.InternalError,
            `Ollama API 오류: ${error.response?.data?.error || error.message}`
          );
        }
        throw new McpError(ErrorCode.InternalError, `채팅 완성에 실패했습니다: ${formatError(error)}`);
      }
    }
  • src/index.ts:24-54 (registration)
    MCP server capabilities declaration registering mcp_ollama_chat_completion as a supported tool.
    capabilities: {
      tools: {
        mcp_sparql_execute_query: true,
        mcp_sparql_update: true,
        mcp_sparql_list_repositories: true,
        mcp_sparql_list_graphs: true,
        mcp_sparql_get_resource_info: true,
        mcp_ollama_run: true,
        mcp_ollama_show: true,
        mcp_ollama_pull: true,
        mcp_ollama_list: true,
        mcp_ollama_rm: true,
        mcp_ollama_chat_completion: true,
        mcp_ollama_status: true,
        mcp_http_request: true,
        mcp_openai_chat: true,
        mcp_openai_image: true,
        mcp_openai_tts: true,
        mcp_openai_transcribe: true,
        mcp_openai_embedding: true,
        mcp_gemini_generate_text: true,
        mcp_gemini_chat_completion: true,
        mcp_gemini_list_models: true,
        mcp_gemini_generate_images: false,
        mcp_gemini_generate_image: false,
        mcp_gemini_generate_videos: false,
        mcp_gemini_generate_multimodal_content: false,
        mcp_imagen_generate: false,
        mcp_gemini_create_image: false,
        mcp_gemini_edit_image: false
      },
  • src/index.ts:73-123 (registration)
    Generic MCP CallToolRequestSchema handler that locates tool by name from tools array and executes its handler.
    server.setRequestHandler(CallToolRequestSchema, async (request: any, _extra: any) => {
      try {
        const tool = tools.find(t => t.name === request.params.name);
        if (!tool) {
          return {
            content: [{
              type: "text" as const,
              text: `알 수 없는 도구: ${request.params.name}`
            }]
          } as ToolResponse;
        }
    
        // 도구가 인수를 필요로 하는 경우에만 인수 유효성 검사
        if (tool.inputSchema.required && tool.inputSchema.required.length > 0) {
          const args = request.params.arguments || {};
          const missingArgs = tool.inputSchema.required.filter(
            arg => !(arg in args)
          );
          if (missingArgs.length > 0) {
            return {
              content: [{
                type: "text" as const,
                text: `필수 인수가 누락되었습니다: ${missingArgs.join(', ')}`
              }]
            } as ToolResponse;
          }
        }
    
        // 도구 실행 - 타입 어설션 사용
        const response = await tool.handler(request.params.arguments || {} as any);
    
        // 메타데이터가 제공된 경우 추가
        if (request.params._meta) {
          return {
            ...response,
            _meta: request.params._meta
          };
        }
    
        return response;
    
      } catch (error) {
        console.error('도구 실행 오류:', error);
        return {
          content: [{
            type: "text" as const,
            text: error instanceof Error ? error.message : '예기치 않은 오류가 발생했습니다'
          }]
        } as ToolResponse;
      }
    }) as any; // MCP SDK 호환성을 위한 타입 단언
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions using an 'OpenAI-compatible API' but doesn't specify authentication requirements, rate limits, error handling, or what the response format looks like. For a chat completion tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Korean that directly states the tool's function. It's appropriately sized for a straightforward tool, though it could be slightly more informative without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a chat completion tool with no annotations and no output schema, the description is incomplete. It doesn't explain the return format, error conditions, or behavioral traits like whether it's read-only or destructive. For a tool with 4 parameters and significant functionality, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning about parameters beyond what's in the schema, such as explaining the purpose of the 'model' parameter or how 'temperature' affects responses. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states it 'generates responses using OpenAI-compatible chat completion API', which identifies the verb (generate) and resource (responses) but is vague about the specific implementation (Ollama). It doesn't distinguish from siblings like 'mcp_openai_chat' which likely serves a similar purpose, nor does it clarify it's specifically for Ollama models rather than general OpenAI API calls.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'mcp_openai_chat' or 'mcp_gemini_chat_completion'. The description doesn't mention any prerequisites, context, or exclusions for usage, leaving the agent to infer based on the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

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/bigdata-coss/agent_mcp'

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