Skip to content

Commit c969fc5

Browse files
committed
fix(chat): wire Sanity Context Knowledge Base MCP tools and org token fallback for Agent AJ
1 parent 8c9c377 commit c969fc5

6 files changed

Lines changed: 483 additions & 52 deletions

File tree

‎.github/workflows/deploy-workers.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,21 @@ jobs:
5151
- name: Configure Cloudflare Worker Secrets (dev)
5252
run: |
5353
echo "$SANITY_API_READ_TOKEN" | pnpm --filter @codingcatdev/site exec wrangler secret put SANITY_API_READ_TOKEN --env=""
54+
if [ -n "$SANITY_AUTH_TOKEN" ]; then
55+
echo "$SANITY_AUTH_TOKEN" | pnpm --filter @codingcatdev/site exec wrangler secret put SANITY_AUTH_TOKEN --env=""
56+
fi
57+
if [ -n "$SANITY_CONTEXT_TOKEN" ]; then
58+
echo "$SANITY_CONTEXT_TOKEN" | pnpm --filter @codingcatdev/site exec wrangler secret put SANITY_CONTEXT_TOKEN --env=""
59+
fi
5460
if [ -n "$OPENROUTER_API_KEY" ]; then
5561
echo "$OPENROUTER_API_KEY" | pnpm --filter @codingcatdev/site exec wrangler secret put OPENROUTER_API_KEY --env=""
5662
fi
5763
env:
5864
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
5965
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
6066
SANITY_API_READ_TOKEN: ${{ secrets.SANITY_API_READ_TOKEN }}
67+
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
68+
SANITY_CONTEXT_TOKEN: ${{ secrets.SANITY_CONTEXT_TOKEN }}
6169
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
6270

6371
deploy-production:
@@ -97,11 +105,19 @@ jobs:
97105
- name: Configure Cloudflare Worker Secrets (production)
98106
run: |
99107
echo "$SANITY_API_READ_TOKEN" | pnpm --filter @codingcatdev/site exec wrangler secret put SANITY_API_READ_TOKEN --env production
108+
if [ -n "$SANITY_AUTH_TOKEN" ]; then
109+
echo "$SANITY_AUTH_TOKEN" | pnpm --filter @codingcatdev/site exec wrangler secret put SANITY_AUTH_TOKEN --env production
110+
fi
111+
if [ -n "$SANITY_CONTEXT_TOKEN" ]; then
112+
echo "$SANITY_CONTEXT_TOKEN" | pnpm --filter @codingcatdev/site exec wrangler secret put SANITY_CONTEXT_TOKEN --env production
113+
fi
100114
if [ -n "$OPENROUTER_API_KEY" ]; then
101115
echo "$OPENROUTER_API_KEY" | pnpm --filter @codingcatdev/site exec wrangler secret put OPENROUTER_API_KEY --env production
102116
fi
103117
env:
104118
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
105119
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
106120
SANITY_API_READ_TOKEN: ${{ secrets.SANITY_API_READ_TOKEN }}
121+
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
122+
SANITY_CONTEXT_TOKEN: ${{ secrets.SANITY_CONTEXT_TOKEN }}
107123
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}

‎apps/site/.dev.vars.example‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Local secrets for `wrangler dev` / platformProxy. Copy to .dev.vars (gitignored).
22
SANITY_API_READ_TOKEN=
3+
# Optional: Organization-level Sanity Context Viewer token for https://api.sanity.io/v1/context/organizations/ovF2qiKSO/mcp/agent-aj-mcp
4+
SANITY_CONTEXT_TOKEN=
5+
SANITY_AUTH_TOKEN=
36
# Optional: PostHog project key for visitor flows, funnels, and LMS telemetry via /ingest proxy
47
PUBLIC_POSTHOG_KEY=
58
PUBLIC_POSTHOG_HOST=https://us.i.posthog.com

‎apps/site/src/components/ChatModal.astro‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@
9696
</svg>
9797
<span>Top videos</span>
9898
</button>
99+
<button
100+
type="button"
101+
class="ai-prompt-chip inline-flex items-center gap-1.5 text-xs px-3.5 py-2 rounded-full border border-border bg-card hover:bg-accent text-foreground cursor-pointer transition-all font-medium shadow-2xs hover:scale-105"
102+
data-prompt="Tell me a programming dad joke!"
103+
>
104+
<svg class="size-3.5 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
105+
<circle cx="12" cy="12" r="10"></circle>
106+
<path d="M8 14s1.5 2 4 2 4-2 4-2"></path>
107+
<line x1="9" x2="9.01" y1="9" y2="9"></line>
108+
<line x1="15" x2="15.01" y1="9" y2="9"></line>
109+
</svg>
110+
<span>Coding joke</span>
111+
</button>
99112
</div>
100113
</div>
101114
</div>
@@ -139,6 +152,19 @@
139152
</svg>
140153
<span>Top videos</span>
141154
</button>
155+
<button
156+
type="button"
157+
class="ai-prompt-chip shrink-0 inline-flex items-center gap-1.5 text-xs px-3 py-1 rounded-full border border-border bg-card hover:bg-accent text-muted-foreground hover:text-foreground cursor-pointer transition-colors font-medium shadow-2xs"
158+
data-prompt="Tell me a programming dad joke!"
159+
>
160+
<svg class="size-3 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
161+
<circle cx="12" cy="12" r="10"></circle>
162+
<path d="M8 14s1.5 2 4 2 4-2 4-2"></path>
163+
<line x1="9" x2="9.01" y1="9" y2="9"></line>
164+
<line x1="15" x2="15.01" y1="9" y2="9"></line>
165+
</svg>
166+
<span>Coding joke</span>
167+
</button>
142168
</div>
143169

144170
<!-- Input Form -->

‎apps/site/src/pages/.well-known/mcp/server-card.json.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,28 @@ export const GET: APIRoute = async ({ locals }) => {
192192
required: ["mode", "documentId", "field"],
193193
},
194194
},
195+
{
196+
name: "knowledge_base_read",
197+
title: "Read Knowledge Base Entries",
198+
description:
199+
"Read full entries from the CodingCat.dev Sanity Context Knowledge Base (e.g. 'AJ Knowlege Jokes' — programming & tech dad jokes, Git jokes, SQL jokes, Jeff Dean facts, coding culture).",
200+
inputSchema: {
201+
type: "object",
202+
properties: {
203+
knowledgeBaseId: {
204+
type: "string",
205+
description: "The ID of the Knowledge Base to read from.",
206+
},
207+
paths: {
208+
type: "array",
209+
items: { type: "string" },
210+
description:
211+
"List of entry paths to read from the Knowledge Base (up to 20 paths).",
212+
},
213+
},
214+
required: ["knowledgeBaseId", "paths"],
215+
},
216+
},
195217
],
196218
};
197219

0 commit comments

Comments
 (0)