Skip to content

Conversation

@Hchunjun
Copy link
Contributor

@Hchunjun Hchunjun commented Nov 18, 2025

Refactor user ID extraction to use AsyncLocalStorage for better context management.

📋 Description

🔄 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🎨 Style/UI changes
  • ♻️ Code refactoring
  • ⚡ Performance improvements
  • 🧪 Test updates
  • 🔧 Build/CI changes

🧪 Testing

  • I have tested this change locally
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

📱 Screenshots (if applicable)

🔍 Code Review Checklist

  • Code follows the project's coding standards
  • Self-review of the code has been performed
  • Code is properly commented, particularly in hard-to-understand areas
  • Changes generate no new warnings
  • Any dependent changes have been merged and published

📚 Related Issues

🚀 Deployment Notes

📋 Additional Context

Refactor user ID extraction to use AsyncLocalStorage for better context management.
@nullure
Copy link
Member

nullure commented Nov 18, 2025

Please test it locally, if it passes please let me know.

@Hchunjun
Copy link
Contributor Author

Passed testing: Locally running the backend service, the Claude code is configured as follows for mcp; it can achieve priority by using the mcp client to specify the request header x-user-id to obtain the uid, avoiding the uncertainty issue of passing the uid when using mcp with AI

{
"headers": {
"Accept": "application/json, text/event-stream",
"Content-Type": "application/json",
"x-api-key": "oooo",
"x-user-id": "xxxx"
},
"type": "http",
"url": "http://localhost:8080/mcp"
}

@nullure
Copy link
Member

nullure commented Nov 19, 2025

MCP supports many ide's, from the looks of it. Your code might only support claude code, please make it flexible

@ajitam
Copy link
Contributor

ajitam commented Nov 24, 2025

so to confirm right now I'm defining MCP (in VS Code) like this

 "mem": {
      "url": "http://dockint.lan:8080/mcp",
      "type": "http",
      "headers": {
        "x-api-key": "xyz...="
      }
    }

and then I would just change it to

 "mem": {
      "url": "http://dockint.lan:8080/mcp",
      "type": "http",
      "headers": {
        "x-api-key": "xyz...="
        "x-user-id": "my-user-id"
      }
    }

and it would overwrite any user_id which would be set my LLM in tool calling?

That would be great, I just setup a "shared" server and I was asking my self how can this be done. When LLM posted memory with user_id=null it just decided and used something for id - how do I define this otherwise?

@nullure isn't this JSON standard? As far as I understand all major clients will accept this (together with additional header) - but then again - I could be wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants