Implementation:AI QL Tuui dxtStore
| Knowledge Sources | |
|---|---|
| Domains | MCPB, State_Management, User_Config |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
Concrete tool for persisting MCPB bundle user configuration values across sessions, provided by the tuui Electron application.
Description
The useDxtStore Pinia store persists per-bundle user config values (e.g. API keys, model names) using pinia-plugin-persistedstate. getConfig(name) returns the raw config object for a bundle. updateConfigAttribute(name, key, value) sets a single config field. getConfigAttribute(name, key) reads a single field. These values are merged with manifest defaults during McpEvent.init before being sent to the main process.
Usage
Import this store when: rendering a MCPB bundle's user config form, reading user-provided config values during MCP server initialization, or persisting config edits.
Code Reference
Source Location
- Repository: tuui
- File: src/renderer/store/dxt.ts
Signature
export const useDxtStore = defineStore('dxtStore', () => {
const configValues: Ref<Record<string, Record<string, userConfigValue>>>
const updateConfigAttribute: (name: string, key: string, value: userConfigValue) => void
const getConfig: (name: string) => Record<string, userConfigValue> | null
const getConfigAttribute: (name: string, key: string) => userConfigValue | null
return { configValues, getConfig, updateConfigAttribute, getConfigAttribute }
}, {
persist: true
})
export const validateNumberRange: (min: number | undefined, max: number | undefined) => string
Import
import { useDxtStore } from '@/renderer/store/dxt'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Bundle/manifest name |
| key | string | Yes (update/getAttribute) | Config field name |
| value | userConfigValue | Yes (updateAttribute) | Config field value (string/number/boolean) |
Outputs
| Name | Type | Description |
|---|---|---|
| getConfig | null | All config values for a bundle; null if none |
| getConfigAttribute | null | Single field value; null if not set |
Usage Examples
Read and Merge User Config
import { useDxtStore } from '@/renderer/store/dxt'
const dxtStore = useDxtStore()
// Get user-provided values for a bundle
const userConfig = dxtStore.getConfig('my-bundle')
// userConfig = { API_KEY: 'sk-xxx', MODEL: 'gpt-4' }
// These are merged with manifest defaults in McpEvent.init:
// For each config field in manifest.user_config:
// if userConfig[field] is valid → use user value
// else → use manifest default
Update a Config Value
const dxtStore = useDxtStore()
dxtStore.updateConfigAttribute('my-bundle', 'API_KEY', 'sk-new-key')
// Persisted to localStorage via pinia-plugin-persistedstate