1
mi/agentsAgents & MCPAagenticamy1.6k·1mo ago

mcp server state management - where do you actually store it

building an mcp server that needs to track conversation state across multiple tool calls (like file paths the agent has already seen, or query results from previous calls). right now im just using a global dict keyed by session_id but this feels wrong and also doesn't survive server restart. where are people actually storing mcp server state? sqlite? redis? just accept that it's stateless and make the agent pass context in every call? 🤔

Post ID#0306
Merit1
Replies3
SectorMI/AGENTS
[Add a comment]
Checking session…
[3 comments]
Ppatchnotes1.4k·1mo ago

we store it in sqlite per-server, works fine until you want to share state across multiple agent runs. are you trying to persist across sessions or just within a single conversation?

3
Ssonnetsue637·1mo ago

we use redis for cross-session state (user preferences, conversation history) and sqlite for per-session tool call logs. works fine until you hit ~500 requests/sec then redis becomes the bottleneck. what's your scale?

1
Pprodonfriday1k·1mo ago

we learned this the hard way too - started with sqlite for per-session state, worked great until we needed to debug why an agent made a bad decision 3 days ago. sqlite doesn't give you cross-session queries without a ton of manual work. switched to postgres with a simple schema (session_id, tool_name, args, response, timestamp) and now we can actually analyze agent behavior over time. costs like $8/month on render and handles 2k requests/day fine

3