Purpose: Full capability testing of MCP soulfield-kg server and optimized graph Date: 2025-11-14 Database: 319 docs, 1,551 entities, 16,850 relationships (0 isolated nodes)
# Verify MCP server is running
ps aux | grep mcp-server | grep -v grep
# Expected: node backend/services/knowledge-graph/mcp-server.cjs
# Check database health
node backend/scripts/verify-kg-health.cjs
# Expected: Isolated Nodes: 0, Communities: 106
# Ensure environment variables
grep "USE_KNOWLEDGE_GRAPH" .env
# Expected: USE_KNOWLEDGE_GRAPH=1Copy this entire prompt to Codex for comprehensive testing:
I need you to comprehensively test the MCP soulfield-kg server and the optimized knowledge graph. The database has 319 documents, 1,551 entities, 16,850 relationships, and 0 isolated nodes after optimization.
Test all 4 search types with Obsidian-specific queries (231 Obsidian docs in database):
- GRAPH_COMPLETION (search Obsidian reference docs):
await mcp__soulfield_kg__search({
query: "How is the lens framework documented in Obsidian reference files?",
searchType: "GRAPH_COMPLETION",
options: { limit: 5, includeGraph: true, filter: "Obsidian" }
})Verify: Should return Obsidian docs from workspace/docs/Obsidian-v2/
- CHUNKS (search Obsidian topic files):
await mcp__soulfield_kg__search({
query: "GRAPH.md DATABASE.md knowledge graph topics",
searchType: "CHUNKS",
options: { limit: 10 }
})Verify: Should return chunks from workspace/docs/Obsidian-v2/topics/
- INSIGHTS (analyze Obsidian vault structure):
await mcp__soulfield_kg__search({
query: "What are the gaps in Obsidian documentation between agents and services?",
searchType: "INSIGHTS",
options: { includeQuestions: true, path: "Obsidian" }
})Verify: Should analyze relationships between docs/reference/agents/ and docs/reference/services/
- CODE (searches actual source code files - NOT for Obsidian docs):
// ⚠️ CODE search filters for .js/.cjs/.ts files only
// Use CHUNKS instead for finding code references in Obsidian markdown
await mcp__soulfield_kg__search({
query: "kg-sqlite.cjs backend services knowledge-graph",
searchType: "CHUNKS", // Use CHUNKS, not CODE
options: { limit: 10 }
})Verify: Returns Obsidian docs mentioning code files (CHUNKS works, CODE intentionally excludes .md)
Why CODE Doesn't Work for Obsidian:
- CODE search filters:
['.js', '.cjs', '.ts'](backend/services/knowledge-graph/graph-search.cjs:359-380) - Obsidian files are
.md→ excluded by design - CHUNKS mode is the correct choice for searching documentation
Test InfraNodus capabilities:
- Cognitive State Detection:
await mcp__soulfield_kg__search({
query: "marketing strategy customer acquisition growth funnel optimization",
searchType: "INSIGHTS",
options: { detectCognitiveState: true }
})Expected states: BIAS, FOCUSED, DIVERSE, or DISPERSED
- Gap Detection with Scoring:
await mcp__soulfield_kg__search({
query: "Find structural gaps in agent communication patterns",
searchType: "INSIGHTS",
options: { findGaps: true, scoreGaps: true }
})Should return gaps with severity: critical/major/minor
- Evolution Tracking:
await mcp__soulfield_kg__search({
query: "Track knowledge graph evolution over time",
searchType: "INSIGHTS",
options: { trackEvolution: true }
})Expected: 8-stage cycle position (exploration → stabilization)
- Community Detection:
await mcp__soulfield_kg__search({
query: "Identify topic communities in the knowledge graph",
searchType: "GRAPH_COMPLETION",
options: { includeCommunities: true }
})Should identify ~106 communities (natural domain clustering)
Test the new semantic bridges created during optimization:
- Marketing ↔ Finance Bridge:
await mcp__soulfield_kg__search({
query: "How does marketing require metrics from finance?",
searchType: "GRAPH_COMPLETION",
options: { traverseDepth: 2 }
})Should find "requires_metrics_from" relationships
- Knowledge Graph → Agents:
await mcp__soulfield_kg__search({
query: "How does SQLiteKnowledgeGraph provide context to agents?",
searchType: "GRAPH_COMPLETION",
options: { includeRelationships: ["provides_context_to"] }
})Should show context injection pattern
- Lens Validation Chain:
await mcp__soulfield_kg__search({
query: "Which lenses validate marketing agent output?",
searchType: "GRAPH_COMPLETION",
options: { relationshipType: "validates_output_of" }
})Should show TruthLens → marketing connections
Test agent context retrieval patterns:
- Marketing Agent Context:
await mcp__soulfield_kg__search({
query: "Create a viral marketing campaign for SaaS product",
searchType: "GRAPH_COMPLETION",
options: { agent: "marketing", useContext: true }
})- Finance Agent Context:
await mcp__soulfield_kg__search({
query: "Calculate burn rate and runway for startup",
searchType: "GRAPH_COMPLETION",
options: { agent: "finance", useContext: true }
})- SEO Agent Context:
await mcp__soulfield_kg__search({
query: "Optimize content for search rankings",
searchType: "GRAPH_COMPLETION",
options: { agent: "seo", useContext: true }
})- Bulk Query Test:
// Test 10 rapid queries
const queries = [
"marketing strategy", "finance models", "seo keywords",
"graph analysis", "lens validation", "agent routing",
"context retrieval", "embedding service", "test coverage", "builder mvp"
];
for (const q of queries) {
const start = Date.now();
await mcp__soulfield_kg__search({
query: q,
searchType: "CHUNKS",
options: { limit: 5 }
});
console.log(`Query "${q}": ${Date.now() - start}ms`);
}Expected: All queries <100ms
- Large Result Set:
await mcp__soulfield_kg__search({
query: "agent",
searchType: "CHUNKS",
options: { limit: 100 }
})Should handle 100 results without timeout
- Deep Graph Traversal:
await mcp__soulfield_kg__search({
query: "council.js orchestration flow",
searchType: "GRAPH_COMPLETION",
options: { traverseDepth: 5, includeAllPaths: true }
})Test multi-hop reasoning capabilities
- Empty Query:
await mcp__soulfield_kg__search({
query: "",
searchType: "CHUNKS"
})Should return error or empty results gracefully
- Non-existent Entity:
await mcp__soulfield_kg__search({
query: "quantum blockchain AI metaverse",
searchType: "GRAPH_COMPLETION"
})Should handle no results gracefully
- Invalid Search Type:
await mcp__soulfield_kg__search({
query: "test",
searchType: "INVALID_TYPE"
})Should default to CHUNKS or return error
- Test Auto-Context Injection: Verify council.js integration at lines 1432-1439:
// Simulate agent query that should get context
await mcp__soulfield_kg__search({
query: "@marketing Create campaign",
searchType: "GRAPH_COMPLETION",
options: { simulateCouncil: true }
})- Test Hybrid Search:
await mcp__soulfield_kg__search({
query: "TruthLens validation process",
searchType: "GRAPH_COMPLETION",
options: {
useTFIDF: true,
useFTS5: true,
useGraphScoring: true
}
})Should combine all three scoring methods
- Graph Statistics:
await mcp__soulfield_kg__getStats()Expected output:
- documents: 319
- entities: 1,551
- relationships: 16,850
- isolated_nodes: 0
- communities: 106
- density: 1.40%
- Performance Metrics:
await mcp__soulfield_kg__getPerformance()Should show:
- avg_query_time: <150ms
- cache_hit_rate
- memory_usage: ~25MB
After running all tests, verify:
- 3/4 search types work for Obsidian (GRAPH_COMPLETION, CHUNKS, INSIGHTS)
- CODE search correctly excludes .md files (expected behavior)
- Graph connectivity is 100% (0 isolated nodes)
- Semantic bridges work (marketing↔finance, etc.)
- InfraNodus features detect gaps and cognitive states
- Query performance <150ms average
- Agent-specific context retrieval works
- No crashes on edge cases
- Hybrid search combines TF-IDF + FTS5 + graph scoring
- CHUNKS mode successfully finds code references in Obsidian docs
- Performance degradation on queries returning >50 results
- Memory growth with repeated large traversals
- Cache invalidation after database updates
- Timeout on GRAPH_COMPLETION with traverseDepth >3
- All search types functional
- Zero isolated nodes maintained
- Cross-domain queries work via semantic bridges
- Performance within benchmarks (<150ms avg)
- Graceful error handling
- InfraNodus features operational (gaps, cognitive state, evolution)
Report findings with specific query/response examples and any errors encountered.
- In Codex: Copy the entire prompt above and execute systematically
- In Claude Code: Can test individual queries using the Task tool with MCP integration
- Direct Node.js: Run test scripts in
backend/scripts/test-mcp-unified-search.cjs
# Test basic search
curl -X POST http://localhost:3000/search \
-H "Content-Type: application/json" \
-d '{"query": "marketing lens", "searchType": "CHUNKS"}'
# Check MCP server health
curl http://localhost:3000/health
# Run comprehensive test suite
node backend/scripts/test-mcp-unified-search.cjs
# Verify graph metrics
node backend/scripts/verify-kg-health.cjs- Logs:
workspace/data/logs/mcp-server.log - Database:
workspace/data/knowledge-graph.db - Test Results:
backend/tests/mcp-kg-test-results.json
- Functionality: All 4 search types operational
- Performance: Queries average <150ms
- Connectivity: Graph maintains 0 isolated nodes
- Relationships: Semantic bridges enable cross-domain queries
- InfraNodus: Gap detection, cognitive state, evolution tracking work
- Scale: Handles 100+ result sets without degradation
- Integration: Context injection pattern verified
This comprehensive test will validate the entire MCP soulfield-kg implementation including the recent optimizations.