报错信息

SpringAI + MCP 采用 ollama 接入 deepseek, 抛出异常信息 [400] Bad Request - {"error":"registry.ollama.ai/library/deepseek-r1:14b does not support tools"},pom.xml 中引入如下:

<dependency>
	<groupId>org.springframework.ai</groupId>
	<artifactId>spring-ai-core</artifactId>
</dependency>
<dependency>
	<groupId>org.springframework.ai</groupId>
	<artifactId>spring-ai-mcp-server-webmvc-spring-boot-starter</artifactId>
</dependency>
<dependency>
	<groupId>org.springframework.ai</groupId>
	<artifactId>spring-ai-ollama-spring-boot-starter</artifactId>
</dependency>

properties 配置如下:

# Spring AI api-key
spring.ai.ollama.base-url=http://10.117.56.221:11434
spring.ai.ollama.chat.options.model=deepseek-r1:14b

# MCP服务端开启
spring.ai.mcp.server.enabled=true

故障原因

出现这个报错的原因是,deepseek-r1 模型无法作为一个 MCP Tool Calling 使用,ollama 上面支持 tools 的模型有:https://ollama.com/search?c=tools

解决方案

访问 https://ollama.com/search?c=tools,下载合适的模型
在这里插入图片描述

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐