Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ node_modules
.env
.env.local
.env.dev
.env.production
packages/db/dist
apps/mcp-server/dist
coverage
Expand Down
6 changes: 5 additions & 1 deletion apps/webapp/server/trpc/routes/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ Example response:
usedFactIds.map(async (factId) => {
try {
const fact = await Fact.findById(factId);
if (fact && !fact.trashed) {
if (
fact &&
!fact.trashed &&
fact.workspace_id === ctx.workspaceId
) {
return {
id: fact.id,
content: fact.content,
Expand Down
8 changes: 5 additions & 3 deletions docs/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -1911,9 +1911,10 @@ KnowledgePlane includes an AI chat interface that combines OpenAI's language mod
7. AI generates a response using both its training and the knowledge base facts accessed via MCP tools
8. AI returns JSON response with `content` (the response text) and `usedFacts` (array of fact IDs actually used)
9. System parses the JSON response and fetches the actual fact objects by IDs
10. Assistant response content is stored in the thread
11. Response is displayed with information about which facts were actually used to construct the response
12. When the user switches workspaces, the chat automatically uses the new workspace's context for subsequent MCP operations
10. System enforces a workspace boundary check (`fact.workspace_id === current workspace`) before returning cited facts
11. Assistant response content is stored in the thread
12. Response is displayed with information about which facts were actually used to construct the response
13. When the user switches workspaces, the chat automatically uses the new workspace's context for subsequent MCP operations

**Thread Management:**
- Each user automatically gets a thread per workspace that persists across sessions
Expand Down Expand Up @@ -1950,6 +1951,7 @@ The chat interface automatically:
- Uses MCP tools to give the AI model direct access to the knowledge base
- Tracks which facts were actually used by the AI model (not just searched)
- Returns only the facts that were actually used to construct the response
- Enforces server-side workspace scoping for cited facts, even if the model returns arbitrary fact IDs

**MCP Integration:**
- The chat interface uses OpenAI's MCP (Model Context Protocol) tools feature
Expand Down
Loading