MCP ExplorerExplorer

Sample S3 Model Context Protocol

@aws-sampleson 12 days ago
46 MIT
FreeCommunity
Knowledge Base
#S3#PDF#aws
A sample MCP server for AWS S3 that flexibly fetches objects from S3 such as PDF documents.

Overview

What is Sample S3 Model Context Protocol

The Sample S3 Model Context Protocol Server is an implementation designed to retrieve data from AWS S3, specifically focusing on accessing PDF documents. It serves as a bridge for loading information into a Language Model (LLM)'s context, facilitating easy data access and retrieval through defined resources.

Use cases

This server can be utilized in applications requiring the extraction of PDF documents stored in S3 buckets, such as document analysis, content generation using LLMs, or integrating PDF data into conversational agents. It is particularly useful in environments where quick and scalable access to a large number of documents is needed.

How to use

Users need to configure their AWS credentials to allow the server access to S3. Once set up, the server can be run using specified commands based on the operating system, either in development or production mode. An MCP Inspector can also be used for debugging purposes during development.

Key features

Key features of this server include the ability to list S3 buckets and objects, retrieve individual PDF documents, and support for up to 1,000 objects per request. The server is built to integrate seamlessly with LLMs, making it easier to incorporate external data into conversational contexts.

Where to use

The S3 MCP server can be used in various scenarios, including data analysis platforms, chatbots requiring access to document databases, educational tools for retrieving research papers, and any application that leverages large language models for processing information from PDF files stored in S3.

Content

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

  1. 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
  2. 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

Development/Unpublished Servers Configuration
{
  "mcpServers": {
    "s3-mcp-server": {
      "command": "uv",
      "args": [
        "--directory",
        "/Users/user/generative_ai/model_context_protocol/s3-mcp-server",
        "run",
        "s3-mcp-server"
      ]
    }
  }
}
Published Servers Configuration
{
  "mcpServers": {
    "s3-mcp-server": {
      "command": "uvx",
      "args": [
        "s3-mcp-server"
      ]
    }
  }
}

Development

Building and Publishing

To prepare the package for distribution:

  1. Sync dependencies and update lockfile:
uv sync
  1. Build package distributions:
uv build

This will create source and wheel distributions in the dist/ directory.

  1. Publish to PyPI:
uv publish

Note: You’ll need to set PyPI credentials via environment variables or command flags:

  • Token: --token or UV_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.

Tools

No tools

Comments