Stardew Valley SMAPI mod — HTTP API for external control + in-game AI chat.
Grab
NagiBridge.zipfrom the link above — it already contains the compiledNagiBridge.dll. You do not need to build anything.
- Install SMAPI
- Download
NagiBridge.zipfrom Releases and unzip it - Move the unzipped
NagiBridgefolder into yourStardew Valley/Mods/folder (so you end up withStardew Valley/Mods/NagiBridge/NagiBridge.dll+manifest.json) - Launch the game through SMAPI
First launch auto-generates config.json. The mod is built for Stardew Valley 1.6+ / SMAPI 4.0+ and the same .dll works on Windows, macOS and Linux.
Cloning the source repo? There is no
.dllin the source tree — it ships only in Releases. If you cloned/downloaded the code and SMAPI says it can't findNagiBridge.dll, download the release zip above, or build it yourself (see below).
Requires the .NET SDK (6.0+) and a local Stardew Valley install.
dotnet build -c ReleaseThe project uses Pathoschild.Stardew.ModBuildConfig, which auto-detects your game folder (Steam / GOG / Xbox on any OS) and copies the built mod straight into Stardew Valley/Mods/NagiBridge/. No paths to edit. If auto-detection fails, set a GamePath property or GAME_PATH environment variable pointing at your install.
Game starts an HTTP server on localhost:7842 (host) / 7843 (farmhand).
Full endpoint list: see AGENTS.md
Press ` (backtick, keyboard top-left) to open the chat panel.
┌─────────────────────────┐
│ Nagi Chat │
│ │
│ > API Mode │
│ Channel Mode │
│ │
│ Up/Down = Select │
│ Enter = OK │
└─────────────────────────┘
- API Mode — Connect to an LLM API (Claude, DeepSeek, OpenAI, or any compatible endpoint). The AI chats with you in-game.
- Channel Mode — Connect to Claude Code via a local channel server. Claude Code controls the game and chats through the panel.
After selecting a mode, you'll be prompted to enter a display name for the AI (default: "Nagi").
Press Tab (when input is empty) in the chat panel to return to mode selection. Switch between API and Channel at any time.
For chatting with an LLM directly in-game. No external tools required.
- Select API Mode → enter display name → press Enter
- API Key — Paste your key with
Ctrl+V(shown as****abcd) - URL — Auto-filled based on provider. Custom endpoints supported.
- Press Enter to connect
| Provider | URL | Model |
|---|---|---|
| DeepSeek | https://api.deepseek.com/v1/chat/completions |
deepseek-chat |
| Claude | https://api.anthropic.com/v1/messages |
claude-sonnet-4-6-20250514 |
| OpenAI | https://api.openai.com/v1/chat/completions |
gpt-4o |
| Custom | Any OpenAI-compatible endpoint | Any model name |
The provider is auto-detected from the URL. Custom URLs use OpenAI-compatible format.
{
"Mode": "",
"ApiProvider": "deepseek",
"ApiUrl": "",
"ApiKey": "",
"Model": "deepseek-chat",
"SystemPrompt": "You are a friendly AI companion in Stardew Valley...",
"MaxHistoryMessages": 20
}- API key is saved locally after first entry. Next launch auto-fills (masked with stars).
- Chat history persists across game restarts in
chat_history.json. - SystemPrompt — Customize the AI's personality.
- MaxHistoryMessages — How many turns to include in API calls (memory window).
For LLMs that support tool calling (function calling), a standalone Python agent lets the AI actually play the game:
python scripts/tool_agent.py --provider deepseek --key sk-xxx --port 7842The AI can use 17 game tools: get_state, warp, move_to, use_tool, farm, mine, harvest, etc.
See scripts/tool_agent.py for details.
For connecting to Claude Code (CC). CC controls the game via HTTP API and chats through the panel.
Game ChatHud → POST → channel_server.py (:9000) → inbox file → CC Monitor → CC responds
↓
Game ChatHud ← /chat/push (:7842) ←────────────────────────────────────────────┘
Each new CC session needs two things:
1. Start channel server:
bash ~/source/NagiBridge/scripts/start_channel.shOr manually:
cd scripts && python channel_server.py &2. Start message monitor (CC tool):
Monitor(description="stardew chat", persistent=true,
command="tail -f ~/nagi/overlay_inbox.jsonl | grep --line-buffered text")
3. Reply to player via API:
curl -X POST http://localhost:7842/chat/push \
-H "Content-Type: application/json" \
-d '{"sender":"Nagi","message":"Hello!"}'{
"Mode": "cc",
"ChannelServerUrl": "http://localhost:9000/chat"
}When Mode is "cc", the chat panel opens directly in Channel mode (skips mode selection).
| Key | Action |
|---|---|
| ` | Open / close chat panel |
| Enter | Send message |
| Tab | Switch mode (when input is empty) |
| Ctrl+V | Paste from clipboard |
| Scroll | Browse message history |
When the chat panel is closed, the last 2 messages are shown as a preview above the toolbar (bottom-left corner).
Python scripts for common farm tasks. Require requests package.
pip install requests| Script | Usage |
|---|---|
farm_row.py |
python farm_row.py 64 18 10 --seed "Melon Seeds" --rows 3 |
water_crops.py |
python water_crops.py --port 7842 |
harvest.py |
python harvest.py 60 17 70 20 --sell |
mine_run.py |
python mine_run.py --start-level 1 --max-levels 5 |
chop_trees.py |
python chop_trees.py --count 10 |
clear_area.py |
python clear_area.py 60 15 70 25 |
pet_animals.py |
python pet_animals.py |
keg_manager.py |
python keg_manager.py --fruit "Ancient Fruit" |
furnace_manager.py |
python furnace_manager.py --ore "Copper Ore" |
shop_buy.py |
python shop_buy.py --items "493:10,491:6" |
All scripts default to --port 7842. Add PYTHONIOENCODING=utf-8 on Windows.