feat: use mcp beta instead of prompt
Node.js CI / Lint and Test (push) Successful in 1m21s

This commit is contained in:
2025-07-14 14:34:47 -07:00
parent 0fd4218e31
commit 9a845ed80d
4 changed files with 23 additions and 6 deletions
+1 -1
View File
@@ -6,8 +6,8 @@
export const prompt = `You are a support agent named Hikari. Your personality is upbeat and energetic, almost like a magical girl. export const prompt = `You are a support agent named Hikari. Your personality is upbeat and energetic, almost like a magical girl.
Your role is to help NHCarrigan's customer with their questions about our products. Your role is to help NHCarrigan's customer with their questions about our products.
As such, you should be referencing the following sources: As such, you should be referencing the following sources:
- The MCP server you have been provided
- Our documentation, at https://docs.nhcarrigan.com - Our documentation, at https://docs.nhcarrigan.com
- The Model Context Protocol for our documentation, at https://hikari.nhcarrigan.com/api/mcp
- Our source code, at https://git.nhcarrigan.com/nhcarrigan - Our source code, at https://git.nhcarrigan.com/nhcarrigan
- A TypeScript file containing our list of products, at https://git.nhcarrigan.com/nhcarrigan/hikari/raw/branch/main/client/src/app/config/products.ts - if you refer to this, the URL you share with the user should be the human-friendly https://hikari.nhcarrigan.com/products. - A TypeScript file containing our list of products, at https://git.nhcarrigan.com/nhcarrigan/hikari/raw/branch/main/client/src/app/config/products.ts - if you refer to this, the URL you share with the user should be the human-friendly https://hikari.nhcarrigan.com/products.
If a user asks something you do not know, you should encourage them to reach out in our Discord community. If a user asks something you do not know, you should encourage them to reach out in our Discord community.
+9 -1
View File
@@ -30,9 +30,17 @@ export const ai = async (hikari, messages, username, channel) => {
}, 3000); }, 3000);
const parsedPrompt = prompt.replace("{{username}}", username); const parsedPrompt = prompt.replace("{{username}}", username);
const result = await anthropic.beta.messages.create({ const result = await anthropic.beta.messages.create({
betas: ["web-search-2025-03-05"], betas: ["web-search-2025-03-05", "mcp-client-2025-04-04"],
// eslint-disable-next-line @typescript-eslint/naming-convention -- API requirement // eslint-disable-next-line @typescript-eslint/naming-convention -- API requirement
max_tokens: 20_000, max_tokens: 20_000,
// eslint-disable-next-line @typescript-eslint/naming-convention -- API requirement
mcp_servers: [
{
name: "documentation",
type: "url",
url: "https://hikari.nhcarrigan.com/api/mcp",
},
],
messages: messages.map((message) => { messages: messages.map((message) => {
return { return {
content: message.content, content: message.content,
+1 -1
View File
@@ -6,8 +6,8 @@
export const prompt = `You are a support agent named Hikari. Your personality is upbeat and energetic, almost like a magical girl. export const prompt = `You are a support agent named Hikari. Your personality is upbeat and energetic, almost like a magical girl.
Your role is to help NHCarrigan's customer with their questions about our products. Your role is to help NHCarrigan's customer with their questions about our products.
As such, you should be referencing the following sources: As such, you should be referencing the following sources:
- The MCP server you have been provided
- Our documentation, at https://docs.nhcarrigan.com - Our documentation, at https://docs.nhcarrigan.com
- The Model Context Protocol for our documentation, at https://hikari.nhcarrigan.com/api/mcp
- Our source code, at https://git.nhcarrigan.com/nhcarrigan - Our source code, at https://git.nhcarrigan.com/nhcarrigan
- A TypeScript file containing our list of products, at https://git.nhcarrigan.com/nhcarrigan/hikari/raw/branch/main/client/src/app/config/products.ts - if you refer to this, the URL you share with the user should be the human-friendly https://hikari.nhcarrigan.com/products. - A TypeScript file containing our list of products, at https://git.nhcarrigan.com/nhcarrigan/hikari/raw/branch/main/client/src/app/config/products.ts - if you refer to this, the URL you share with the user should be the human-friendly https://hikari.nhcarrigan.com/products.
If a user asks something you do not know, you should encourage them to reach out in our Discord community. If a user asks something you do not know, you should encourage them to reach out in our Discord community.
+12 -3
View File
@@ -41,10 +41,18 @@ export const ai = async(
const parsedPrompt = prompt.replace("{{username}}", username); const parsedPrompt = prompt.replace("{{username}}", username);
const result = await anthropic.beta.messages.create({ const result = await anthropic.beta.messages.create({
betas: [ "web-search-2025-03-05" ], betas: [ "web-search-2025-03-05", "mcp-client-2025-04-04" ],
// eslint-disable-next-line @typescript-eslint/naming-convention -- API requirement // eslint-disable-next-line @typescript-eslint/naming-convention -- API requirement
max_tokens: 20_000, max_tokens: 20_000,
messages: messages.map((message) => { // eslint-disable-next-line @typescript-eslint/naming-convention -- API requirement
mcp_servers: [
{
name: "documentation",
type: "url",
url: "https://hikari.nhcarrigan.com/api/mcp",
},
],
messages: messages.map((message) => {
return { return {
content: message.content, content: message.content,
role: message.author.id === hikari.user?.id role: message.author.id === hikari.user?.id
@@ -62,6 +70,7 @@ export const ai = async(
name: "web_search", name: "web_search",
type: "web_search_20250305", type: "web_search_20250305",
}, },
], ],
}); });
await calculateCost(result.usage, username); await calculateCost(result.usage, username);