Token导航 LogoToken导航TokenDH.com
MCP Llama Integration logo
搜索检索stdio官方级别未说明来源级核验

MCP Llama Integration

MCP Server

一个集成Llama模型的模型上下文协议服务器,为AI应用提供标准化的上下文检索接口。

工具数

2

提示词数

0

GitHub Stars

4

资源数

0
本地LLMPython搜索

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

EXPESRaza

提供方

EXPESRaza

最后核验

2026/5/17 20:19

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -r requirements.txt

详细介绍

具有Llama集成的模型上下文协议服务器

此存储库包含一个与本地运行的Llama模型集成的模型上下文协议(MCP)服务器实现。MCP服务器为上下文检索提供了一个标准化的接口,利用来自本地LLM的相关信息增强AI应用程序。

概述

该项目由两个主要部分组成:

  1. MCP服务器 -基于FastAPI的服务器,实现模型上下文协议并将查询转发到本地Llama模型
  2. Python客户端 -演示如何与MCP服务器交互的示例客户端应用程序

先决条件

  • Python 3.7或更高版本
  • 运行调用模型服务器(例如,Ollama)athttp://localhost:11434/
  • Git已安装在您的计算机上
  • GitHub账号

安装

克隆存储库

git clone https://github.com/EXPESRaza/mcp-llama-integration.git
cd mcp-llama-integration

再进行

pip install -r requirements.txt

文件结构

mcp-llama-integration/
├── llama_mcp_server.py      # MCP server with Llama integration
├── llama_client_app.py      # Sample client application
└── README.md                # Project documentation

设置火焰模型

  1. 如果还没有,请安装 没有
  2. 拉动火焰模型:
   ollama pull llama3.2
  1. 验证模型是否正在运行:
   curl http://localhost:11434/api/tags

http://localhost:11434 http://localhost:11434/api/tags

   ![image](https://gips2.baidu.com/it/u=926124398,1071570902&fm=3081&app=3081&f=PNG?w=338&h=107)

## 运行MCP服务器

1. 启动服务器:

python llama_mcp_server.py


1. 服务器将在上开始运行 `http://localhost:8000`

1. 您可以通过检查运行状况终结点来验证服务器是否正在运行:

curl http://localhost:8000/health


   ![image](https://gips2.baidu.com/it/u=4007058629,4026623187&fm=3081&app=3081&f=PNG?w=559&h=120)

   ![image](https://gips0.baidu.com/it/u=3105598061,4236462181&fm=3081&app=3081&f=PNG?w=805&h=286)

## 使用客户端应用程序

1. 在单独的终端中,启动客户端应用程序:

python llama_client_app.py


1. 应用程序将提示您输入

1. 键入您的查询并接收Llama模型的回复

1. 键入“exit”退出应用程序

   ![image](https://gips0.baidu.com/it/u=2477727618,2044686466&fm=3081&app=3081&f=PNG?w=770&h=418)

## API文档

### MCP服务器端点

#### POST/上下文

请求给定查询的上下文。

**请求正文:**

{ "query_text": "Your query here", "user_id": "optional-user-id", "session_id": "optional-session-id", "additional_context": {} }


**答复:**

{ "context_elements": [ { "content": "Response from Llama model", "source": "llama_model", "relevance_score": 0.9 } ], "metadata": { "processing_time_ms": 150, "model": "llama3", "query": "Your query here" } }


#### GET/健康

检查MCP服务器的运行状况及其与Llama模型的连接。

**答复:**

{ "status": "healthy", "llama_status": "connected" }


## 定制

### 改变火焰模型

如果你想使用不同的Llama模型,请修改 `model` 参数在 `query_llama` 功能在 `llama_mcp_server.py`:

payload = { "model": "your-model-name", # Change this to your model name "prompt": text, "stream": False }


### 修改提示模板

要在发送给Llama之前更改查询的格式,请更新中的提示模板 `get_context` 功能:

prompt = f"""Please provide relevant information for the following query: {request.query_text}

Respond with factual, helpful information."""


## 故障排除

### 常见问题

1. **连接被拒绝错误**

   - 确保火焰模型在运行http://localhost:11434/
   - 验证Ollama是否正确安装并运行

1. **找不到模型错误**

   - 确保你和Ollama拉了正确的模型
   - 检查可用型号 `ollama list`

1. **反应缓慢**

   - Llama模型推理可能是资源密集型的
   - 如果性能有问题,考虑使用较小的模型

## 贡献

欢迎投稿!请随时提交拉取请求。

## 许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。

目录标签

目录标签

本地LLMPython搜索AI接口本地部署上下文检索Llama集成

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

session

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiosession部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP