範例 S3 模型上下文協議伺服器
概覽
什麼是 Sample MCP Server S3?
Sample MCP Server S3 是一個在 GitHub 上由 ### aws-samples 組織托管的公共庫。這個項目展示了如何實現一個與 Amazon S3(簡單存儲服務)互動的伺服器,展示最佳實踐並提供範例代碼,幫助開發者將 S3 整合到他們的應用程序中。該庫包含各種資源,包括代碼片段、文檔和示例,幫助用戶理解如何有效地使用 S3 進行存儲解決方案。
Sample MCP Server S3 的特點
- 與 Amazon S3 的整合:該項目提供了一種無縫的方式來連接和與 S3 互動,使用戶能夠輕鬆上傳、下載和管理文件。
- 公共訪問:作為一個公共庫,它允許開發者訪問代碼、貢獻並從提供的示例中學習。
- 文檔:包含全面的文檔,以指導用戶設置和使用伺服器。
- 社區支持:作為 AWS 範例的一部分,它受益於社區的貢獻和反饋,增強了其功能和可用性。
- 開源:該項目是開源的,允許開發者修改和調整代碼以適應他們的特定需求。
如何使用 Sample MCP Server S3
-
克隆庫:首先使用以下命令將庫克隆到本地機器:
git clone https://github.com/aws-samples/sample-mcp-server-s3.git
-
設置 AWS 憑證:確保您已配置 AWS 憑證。這可以通過設置 AWS CLI 或在應用程序配置中提供憑證來完成。
-
安裝依賴項:導航到項目目錄並安裝所需的依賴項。這通常涉及運行:
npm install
-
啟動伺服器:使用以下命令啟動伺服器:
npm start
-
訪問應用程序:一旦伺服器運行,您可以通過網頁瀏覽器或 API 客戶端訪問應用程序以與 S3 互動。
-
探索代碼:查看提供的示例和文檔,以了解如何實現各種功能和特性。
常見問題解答
什麼是 Amazon S3?
Amazon S3(簡單存儲服務)是 AWS 提供的一種可擴展對象存儲服務,允許用戶從網絡上的任何地方存儲和檢索任意數量的數據。它廣泛用於備份、存檔和網絡應用程序的數據存儲。
Sample MCP Server S3 是免費使用的嗎?
是的,Sample MCP Server S3 是一個開源項目,免費使用。然而,根據您的使用情況,您可能會產生與使用 AWS 服務(如 S3)相關的費用。
我可以為 Sample MCP Server S3 做貢獻嗎?
當然可以!歡迎貢獻。您可以分叉庫,進行更改,並提交拉取請求以供審核。
我可以在哪裡找到有關 AWS S3 的更多信息?
您可以在 官方 AWS 文檔 上找到有關 AWS S3 的更多信息。這包括詳細指南、API 參考和有效使用 S3 的最佳實踐。
詳細
Sample S3 Model Context Protocol Server
An MCP server implementation for retrieving data such as PDF's from S3.
Features
Resources
Expose AWS S3 Data through Resources. (think of these sort of like GET endpoints; they are used to load information into the LLM's context). Currently only PDF documents supported and limited to 1000 objects.
Tools
- ListBuckets
- Returns a list of all buckets owned by the authenticated sender of the request
- ListObjectsV2
- Returns some or all (up to 1,000) of the objects in a bucket with each request
- GetObject
- Retrieves an object from Amazon S3. In the GetObject request, specify the full key name for the object. General purpose buckets - Both the virtual-hosted-style requests and the path-style requests are supported
Configuration
Setting up AWS Credentials
- Obtain AWS access key ID, secret access key, and region from the AWS Management Console and configure credentials files using Default profile as shown here
- Ensure these credentials have appropriate permission READ/WRITE permissions for S3.
Usage with Claude Desktop
Claude Desktop
On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"s3-mcp-server": {
"command": "uv",
"args": [
"--directory",
"/Users/user/generative_ai/model_context_protocol/s3-mcp-server",
"run",
"s3-mcp-server"
]
}
}
}
</details>
<details>
<summary>Published Servers Configuration</summary>
{
"mcpServers": {
"s3-mcp-server": {
"command": "uvx",
"args": [
"s3-mcp-server"
]
}
}
}
</details>
Development
Building and Publishing
To prepare the package for distribution:
- Sync dependencies and update lockfile:
uv sync
- Build package distributions:
uv build
This will create source and wheel distributions in the dist/
directory.
- Publish to PyPI:
uv publish
Note: You'll need to set PyPI credentials via environment variables or command flags:
- Token:
--token
orUV_PUBLISH_TOKEN
- Or username/password:
--username
/UV_PUBLISH_USERNAME
and--password
/UV_PUBLISH_PASSWORD
Debugging
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.
You can launch the MCP Inspector via npm
with this command:
npx @modelcontextprotocol/inspector uv --directory /Users/user/generative_ai/model_context_protocol/s3-mcp-server run s3-mcp-server
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
Security
See CONTRIBUTING for more information.
License
This library is licensed under the MIT-0 License. See the LICENSE file.
伺服器配置
{
"mcpServers": {
"sample-mcp-server-s-3": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/metorial/mcp-container--aws-samples--sample-mcp-server-s3--sample-mcp-server-s-3",
"s3-mcp-server"
],
"env": {}
}
}
}