# Nakama MCP

> Nakama MCP connects your game's backend infrastructure directly to any AI client. Use natural conversation to manage authentication, update player profiles, handle social interactions like friend lists and groups, or read/write global data and leaderboards. It lets you run complex game logic and manage user accounts without ever leaving your IDE.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Tags:** game-backend, multiplayer, social-gaming, leaderboards, real-time

## Description

This MCP connects the backend of your real-time multiplayer games directly to your AI client. You can treat your game's infrastructure like a set of functions, invoking them through simple natural language prompts. Instead of logging into a separate dashboard or running complex API calls manually, you simply ask your agent to perform actions—like adding friends, updating an account profile, or fetching the top scores on a leaderboard. Whether you need to create a new group for a guild or verify that player inventory data is correct in storage, this MCP handles it. By connecting through Vinkius, you get access to all these core game mechanics from one place. It lets developers and live ops managers test backend logic, debug data objects, and manage the entire player lifecycle using just conversation.

## Tools

### update_account
Modifies details, like usernames or avatars, for the current user account.

### write_leaderboard_record
Submits a new score entry to a specific leaderboard.

### write_storage_objects
Writes or overwrites data into a specified storage object.

### add_friends
Sends friend invites or adds friends directly through the API.

### add_group_members
Adds specified users to an existing group.

### authenticate_device
Validates a user's identity using only their device ID.

### authenticate_email
Logs in a user by providing both an email and password.

### block_friends
Prevents communication with specific users.

### create_group
Establishes a brand new user group within the game system.

### delete_account
Permanently removes the current user's account from the platform.

### delete_friends
Removes a friend connection or declines an incoming invite.

### delete_storage_objects
Deletes specified objects from the game's storage system.

### demote_group_members
Reduces the rank or status of a member within a group.

### get_account
Retrieves and displays the profile information for the current user account.

### get_channel_history
Fetches a log of messages from a specific channel.

### get_users
Retrieves public profile details for any user on the platform.

### join_group
Allows the current user to become a member of an existing group.

### join_tournament
Registers the user to participate in a specific tournament.

### kick_group_members
Forcibly removes one or more members from a group.

### leave_group
Removes the current user from their assigned group.

### list_friends
Shows all of the friends currently connected to the user account.

### list_groups
Retrieves a list of groups the user is associated with.

### list_leaderboard_records
Pulls all recorded entries from specified leaderboards.

### list_storage_objects
Retrieves a list of available storage objects for inspection.

### logout_session
Ends the current user's session, requiring re-authentication.

### promote_group_members
Increases the rank or status of one or more members within a group.

### read_storage_objects
Reads and displays the content stored in a specified data object.

### refresh_session
Extends the validity period of an existing session token.

### rpc_call
Executes any custom function (Remote Procedure Call) defined on the game server.

### list_tournaments
Gets the names and details of all active tournaments.

### write_tournament_record
Records the final placement score for a user in a tournament.

## Prompt Examples

**Prompt:** 
```
Authenticate a user with email 'player@example.com' and password 'securePass123'.
```

**Response:** 
```
I've initiated the authentication for 'player@example.com'. The session is now active and the user is logged in.
```

**Prompt:** 
```
Show me the top records for the 'global_high_scores' leaderboard.
```

**Response:** 
```
Fetching leaderboard data... I've retrieved the top records for 'global_high_scores'. The current leader is 'PlayerOne' with 15,000 points.
```

**Prompt:** 
```
List all the groups I am currently a member of.
```

**Response:** 
```
Querying your group memberships... You are currently a member of 3 groups: 'Alpha Squad', 'Beta Testers', and 'The Guild'.
```

## Capabilities

### Manage User Identity
Authenticate users via email or device ID, refresh sessions, or log out accounts.

### Control Social Features
Handle all group management tasks, including creating groups, adding members, promoting ranks, and managing friend lists.

### Read and Write Game Data
Manage persistent player state by listing, reading, writing, or deleting data objects in the game storage.

### Track Competition
Access current leaderboard records, list available tournaments, and write new scores for players to track.

### Execute Custom Logic
Trigger specific server-side functions (RPC calls) to run custom game logic or integrations.

## Use Cases

### A player's friend profile seems wrong.
The developer needs to check if PlayerX is correctly listed as friends with the user. Instead of calling the internal API directly, they prompt their agent: 'List my friends and verify that PlayerX is included.' The agent executes `list_friends` and returns the list for immediate review.

### A new competitive season starts.
The ops manager needs to set up the initial leaderboards. They prompt: 'First, list all current tournaments using `list_tournaments`. Then, write a starting record for PlayerY's score.' The agent executes both actions sequentially.

### A guild member gets promoted.
The backend engineer needs to update the group hierarchy. They prompt: 'Promote MemberZ within the Alpha Squad group.' The agent uses `promote_group_members` and confirms the status change, allowing instant validation.

### A user loses their session token.
The support team member needs to verify the user's identity before assisting. They ask the agent: 'Authenticate this user using their device ID.' The agent uses `authenticate_device` and confirms if a valid, refreshed session is active.

## Benefits

- Don't waste time switching contexts. You can authenticate users or fetch player profiles—using tools like `authenticate_email` and `get_account`—all from a single chat window within your IDE.
- Speed up live ops work by managing social features conversationally. Instead of clicking through three separate menus to manage groups, you just ask the agent to `create_group` or `add_group_members`.
- Debug player data instantly. Use tools like `read_storage_objects` and `list_storage_objects` to verify if a user's inventory or state is correctly saved in your backend storage.
- Keep track of competitive play effortlessly. You can list tournaments using `list_tournaments`, then write results with `write_tournament_record`, all without writing boilerplate code.
- Simplify group governance. Instead of manually promoting members, you can simply tell the agent to `promote_group_members` or `kick_group_members` and see it happen instantly.
- Access custom logic easily. If a feature requires complex backend processing, use the simple `rpc_call` tool instead of building out a full boilerplate endpoint just for testing.

## How It Works

The bottom line is you manage your entire game backend from one conversational interface in your preferred IDE.

1. Subscribe to this MCP on Vinkius and provide your Nakama Server URL and Session Token.
2. Your AI client uses the provided credentials to establish a connection to the game backend's API endpoints.
3. You issue a natural language command (e.g., 'Add PlayerX to the Beta Group'), and the agent translates that into the necessary tool call, executing the action on the live server.

## Frequently Asked Questions

**How do I authenticate a user with the Nakama MCP?**
You can use `authenticate_email` if you have their credentials. Alternatively, if they are already logged in via an app, you can run `refresh_session` to keep the connection active.

**Can I create new groups with Nakama MCP?**
Yes, use the `create_group` tool. This allows your agent to establish a brand new group ID and structure within the game's ecosystem for you.

**What is the best way to check stored player data using Nakama MCP?**
To see what data exists, start by calling `list_storage_objects`. Then, use `read_storage_objects` with a specific object name to pull the actual content.

**How do I simulate a player scoring on a leaderboard?**
You execute this using `write_leaderboard_record`. You provide the record ID, score value, and the user's identifying information, simulating a real game event.

**Can Nakama MCP manage friend lists for me?**
Yes. To add friends, you use `add_friends`. If you need to remove them or reject an invite, run the `delete_friends` tool.

**Can I register new players using this server?**
Yes. Use `authenticate_email` or `authenticate_device` with the `create` flag set to true. This will register a new account if the credentials don't already exist.

**How do I retrieve a player's virtual wallet or metadata?**
Use the `get_account` tool. It returns the full profile, including the wallet JSON and any linked device identifiers for the authenticated user.

**Can I trigger custom server-side logic?**
Absolutely. Use the `rpc_call` tool by providing the specific Function ID. This allows your AI agent to execute any custom Lua, Go, or TypeScript modules you've deployed.