|
| 1 | +# SMACK - Message Storage Service |
| 2 | + |
| 3 | +SMACK is a simple messaging service with a persistent message store using PostgreSQL. It's designed to work with the Model Context Protocol (MCP) Inspector for easy testing and interaction. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +SMACK is built on the MCP Engine, a secure implementation of the Model Context Protocol (MCP) with authentication support. While MCP standardizes interactions between AI models and external systems, early implementations lacked key features for security, scalability, and reliability. MCP Engine addresses these by integrating OAuth 2.1, ensuring secure and seamless communication. |
| 8 | + |
| 9 | +SMACK serves as a practical demonstration of the MCP Engine's capabilities by providing a basic yet functional messaging service. It highlights the importance of authentication and provides a hands-on experience with secure AI interactions. |
| 10 | + |
| 11 | +For a visual representation of the architecture and how SMACK integrates with the MCP Engine, please refer to the diagram below: |
| 12 | + |
| 13 | +<a href="https://spec.modelcontextprotocol.io/specification/2025-03-26/basic/authorization/" target="_blank"> |
| 14 | + <img src="https://cdn.prod.website-files.com/60cce6512b4ab924a0427124/67ec3d30ae1829e736099100_AD_4nXfpxfRMRgTM8glCYWi-YjhvxBvM3qAS73e58YRbCT8xtVnDwipEhT6NhLxssr5xH7jw-d6HoJByggT7QtOIsXYuG8MYbVtiV2aeNPiXDlIGjIF6zIKhaCrO4AdmGAUmuHLXgBzX.png" alt="MCP Authorization Flow" width="500"> |
| 15 | +</a> |
| 16 | + |
| 17 | +This diagram illustrates the flow of data and the role of authentication in ensuring secure interactions within the SMACK service. |
| 18 | + |
| 19 | +We encourage you to explore SMACK to understand the critical role of authentication and scalability in MCP-based interactions and to experience firsthand the enhancements brought by the MCP Engine. |
| 20 | + |
| 21 | +## Features |
| 22 | + |
| 23 | +- OAuth 2.1 authentication |
| 24 | +- Persistent message storage using PostgreSQL |
| 25 | +- Docker containerization for easy deployment |
| 26 | + |
| 27 | +## Prerequisites |
| 28 | + |
| 29 | +- Docker and Docker Compose |
| 30 | +- MCP Inspector (for testing and interaction) |
| 31 | +- npx (optional) |
| 32 | + |
| 33 | +## Quick Start |
| 34 | + |
| 35 | +### 1. Clone the repository and navigate to the examples/smack directory |
| 36 | + |
| 37 | +### 2. Start the service using Docker Compose: |
| 38 | + ```bash |
| 39 | + docker-compose up --build |
| 40 | + ``` |
| 41 | + This will: |
| 42 | + - Build and start the SMACK server on port 8000 |
| 43 | + - Start a PostgreSQL instance on port 5432 |
| 44 | + - Create necessary volumes for data persistence |
| 45 | + |
| 46 | +### 3. Connect to the service |
| 47 | + You can use our proxy server to connect SMACK to your client. |
| 48 | + Navigate to the proxy directory and build the main file: |
| 49 | + |
| 50 | + ```bash |
| 51 | + cd src/mcp/proxy |
| 52 | + go build main.go |
| 53 | + ``` |
| 54 | + |
| 55 | + There are multiple ways to interact with SMACK: |
| 56 | + |
| 57 | + #### a. Using the MCP Inspector |
| 58 | + In a separate terminal run |
| 59 | + |
| 60 | + ```bash |
| 61 | + npx @modelcontextprotocol/inspector ./main <server-url> |
| 62 | + ``` |
| 63 | + In this case the server url is http://localhost:8000/sse. |
| 64 | + |
| 65 | + This will open the MCP inspector in your browser where you can list the tools and interact with the server. |
| 66 | + |
| 67 | + #### b. Using Claude Desktop |
| 68 | + Create the config file if it doesn't exist: |
| 69 | + |
| 70 | + ```bash |
| 71 | + touch ~/Library/Application\ Support/Claude/claude_desktop_config.json |
| 72 | + ``` |
| 73 | + Add the following to the file: |
| 74 | + ```json |
| 75 | + { |
| 76 | + "mcpServers": { |
| 77 | + "smack_mcp_server": { |
| 78 | + "command": "path/to/repo/mcp_engine/src/mcp/proxy/main", |
| 79 | + "args": [ |
| 80 | + "http://localhost:8000/sse" |
| 81 | + ] |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + ``` |
| 86 | + |
| 87 | + Save the file and restart Claude Desktop. You should now see the SMACK server in the list of available servers. |
| 88 | + You can now use Claude to send messages and list messages on SMACK. |
| 89 | + |
| 90 | +## Available Tools |
| 91 | + |
| 92 | +### `list_messages()` |
| 93 | +Retrieves all posted messages from the database. |
| 94 | + |
| 95 | +**Response Format:** |
| 96 | +``` |
| 97 | +1. sender: message content |
| 98 | +2. sender: message content |
| 99 | +... |
| 100 | +``` |
| 101 | + |
| 102 | +### `post_message(sender: str, message: str)` |
| 103 | +Posts a new message to the database. |
| 104 | + |
| 105 | +**Parameters:** |
| 106 | +- `sender`: The sender of the message |
| 107 | +- `message`: The text content you want to post |
| 108 | + |
| 109 | +**Response:** |
| 110 | +- Success: "Message posted successfully: '{message}'" |
| 111 | +- Failure: Error message if the post failed |
0 commit comments