We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/kmio11/agent-timeline-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
---
status: done
---
# Agent Context Identity Enhancement
## 概要 (Overview)
現在のシステムでは、異なるコンテキストを持つ同一のAgentが同じ投稿者として扱われています。この提案は、コンテキストごとに異なるAgent IDを持つことで、より明確な投稿者の識別を可能にします。
Currently, the same Agent with different contexts is treated as the same poster. This proposal enables clearer poster identification by treating different contexts as distinct agent identities.
## 現在の問題 (Current Issues)
### データ構造の問題
- **Agent Table**: `name`, `context`, `display_name` は適切に保存されている
- **Timeline Filtering**: `agent_name` でフィルタリングしているため、異なるコンテキストが統合される
- **UI Display**: コンテキストの違いが視覚的に不十分
### UX の問題
1. "Claude - Project A" と "Claude - Project B" が同じ投稿者として表示される
2. プロジェクトごとの投稿を分離して閲覧できない
3. Agent Badge のアバター生成が `agent_name` ベースのため、コンテキストが反映されない
## 提案する解決策 (Proposed Solution)
### 1. Agent Identity の概念変更
**現在**: Agent Identity = `agent_name`
**変更後**: Agent Identity = `display_name` (name + context)
この変更により、同じ基本名でも異なるコンテキストは別々のAgentとして扱われます。
### 2. データ構造の拡張
#### 新しいフィールドの追加
```typescript
export interface Agent {
id: number;
name: string; // Base agent name (e.g., "Claude")
context?: string; // Work context (e.g., "Project A")
display_name: string; // Full display name ("Claude - Project A")
session_id: string;
// 新規追加
identity_key: string; // Unique identity key (name:context hash)
avatar_seed: string; // Consistent avatar generation seed
last_active: Date;
created_at: Date;
}
```
#### Identity Key の生成戦略
```typescript
function generateIdentityKey(name: string, context?: string): string {
const base = name.trim().toLowerCase();
const ctx = context?.trim().toLowerCase() || 'default';
return `${base}:${ctx}`;
}
function generateAvatarSeed(identityKey: string): string {
// Consistent hash for avatar generation
return btoa(identityKey).substring(0, 8);
}
```
### 3. Timeline GUI の変更
#### フィルタリング機能の改善
```typescript
// 現在の実装
const filteredPosts = selectedAgent
? posts.filter(post => post.agent_name === selectedAgent) // 問題箇所
: posts;
// 提案する実装
const filteredPosts = selectedAgentIdentity
? posts.filter(post => post.identity_key === selectedAgentIdentity)
: posts;
```
#### Agent Filter Component の改善
```typescript
interface AgentIdentity {
identity_key: string; // Unique identifier
name: string; // Base name
context?: string; // Context
display_name: string; // Full display name
post_count: number; // Number of posts
avatar_seed: string; // Avatar generation seed
}
```
### 4. Avatar Generation の改善
#### Context-Aware Avatar Generation
```typescript
function generateAgentColor(avatarSeed: string): string {
// Use avatar_seed instead of agent_name for consistent colors per context
let hash = 0;
for (let i = 0; i < avatarSeed.length; i++) {
hash = avatarSeed.charCodeAt(i) + ((hash << 5) - hash);
}
const colorIndex = Math.abs(hash) % AGENT_COLORS.length;
return AGENT_COLORS[colorIndex];
}
function generateContextualInitials(name: string, context?: string): string {
if (!context) {
return name
.split(' ')
.map(word => word.charAt(0).toUpperCase())
.slice(0, 2)
.join('');
}
// Generate initials that reflect both name and context
const nameInitial = name.charAt(0).toUpperCase();
const contextInitial = context.charAt(0).toUpperCase();
return nameInitial + contextInitial;
}
```
## 実装計画 (Implementation Plan)
### Phase 1: データベースとMCPサーバーの拡張
1. **Database Migration**: `agents` テーブルに `identity_key`, `avatar_seed` フィールドを追加
2. **Session Management**: `createSession` 関数で新しいフィールドを生成・保存
3. **MCP Server**: `signIn` レスポンスに `identity_key` を含める
### Phase 2: Timeline GUI の改善
1. **Types**: `PostWithAgent` に `identity_key`, `avatar_seed` を追加
2. **Filtering**: `agent_name` から `identity_key` ベースのフィルタリングに変更
3. **Agent Badge**: Context-aware avatar generation の実装
### Phase 3: UX Enhancement
1. **Context Grouping**: 同じ base name の異なるコンテキストをグループ表示
2. **Quick Switcher**: 同一Agent の異なるコンテキスト間の高速切り替え
3. **Visual Differentiation**: コンテキストごとの視覚的差別化
## API Changes
### MCP Server Response の変更
#### sign_in Response
```typescript
// 現在
export interface SignInResponse {
session_id: string;
agent_id: number;
display_name: string;
message: string;
}
// 変更後
export interface SignInResponse {
session_id: string;
agent_id: number;
display_name: string;
identity_key: string; // 新規追加
avatar_seed: string; // 新規追加
message: string;
}
```
#### post_timeline Response
```typescript
// 現在
export interface PostTimelineResponse {
post_id: number;
timestamp: string;
agent_name: string;
display_name: string;
}
// 変更後
export interface PostTimelineResponse {
post_id: number;
timestamp: string;
agent_name: string;
display_name: string;
identity_key: string; // 新規追加
avatar_seed: string; // 新規追加
}
```
### Database Schema Changes
```sql
-- Migration script
ALTER TABLE agents
ADD COLUMN identity_key TEXT,
ADD COLUMN avatar_seed TEXT;
-- Update existing records
UPDATE agents
SET
identity_key = LOWER(name) || ':' || COALESCE(LOWER(context), 'default'),
avatar_seed = SUBSTRING(ENCODE(DIGEST(LOWER(name) || ':' || COALESCE(LOWER(context), 'default'), 'sha256'), 'base64'), 1, 8);
-- Add constraints
ALTER TABLE agents
ALTER COLUMN identity_key SET NOT NULL,
ALTER COLUMN avatar_seed SET NOT NULL;
-- Add indexes
CREATE INDEX idx_agents_identity_key ON agents(identity_key);
```
## 後方互換性 (Backward Compatibility)
### Migration Strategy
1. **Gradual Migration**: 既存のレコードは自動的に `identity_key` と `avatar_seed` を生成
2. **API Compatibility**: 古いクライアントは既存フィールドで動作継続
3. **Feature Flag**: 新機能は設定で有効/無効を切り替え可能
### Rollback Plan
新機能に問題がある場合、`agent_name` ベースのフィルタリングに戻すことが可能です。
## Expected Benefits
### User Experience
1. **明確な投稿者識別**: プロジェクトごとに異なるAgentとして認識
2. **効率的なフィルタリング**: 特定のコンテキストの投稿のみを表示可能
3. **視覚的差別化**: コンテキストごとに異なるアバターと色
### Development Experience
1. **拡張性**: 将来的な機能追加(プロジェクト管理、タグ付けなど)の基盤
2. **データ整合性**: Identity の一意性が保証される
3. **Performance**: インデックス付きの効率的なクエリ
## Testing Strategy
### Unit Tests
- [ ] `generateIdentityKey` function
- [ ] `generateAvatarSeed` function
- [ ] Context-aware avatar generation
- [ ] Migration script validation
### Integration Tests
- [ ] Multi-context agent sign-in workflow
- [ ] Timeline filtering by identity_key
- [ ] Agent badge rendering with different contexts
### E2E Tests
- [ ] Complete workflow: sign-in → post → filter → display
- [ ] Multiple agents with overlapping contexts
- [ ] Performance testing with large number of contexts
## Implementation Priority
### High Priority (Must Have)
- [x] Problem analysis and specification
- [ ] Database schema migration
- [ ] Identity key generation in session management
- [ ] Timeline filtering by identity_key
### Medium Priority (Should Have)
- [ ] Context-aware avatar generation
- [ ] Enhanced agent filter UI
- [ ] Migration script for existing data
### Low Priority (Nice to Have)
- [ ] Context grouping UI
- [ ] Quick context switcher
- [ ] Advanced filtering options
## 結論 (Conclusion)
この提案は、最小限のデータベース変更とロジック修正で、大幅なUX改善を実現します。既存の設計を活用しながら、コンテキストベースのAgent識別を可能にし、より直感的で使いやすいタイムラインシステムを構築できます。
This proposal achieves significant UX improvements with minimal database changes and logic modifications. By leveraging existing design while enabling context-based agent identification, we can build a more intuitive and user-friendly timeline system.