@kavinga/commerce-tools 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/agents/_base.d.ts +10 -0
  2. package/dist/agents/_base.d.ts.map +1 -0
  3. package/dist/agents/_base.js +30 -0
  4. package/dist/agents/_base.js.map +1 -0
  5. package/dist/commands/_registry.d.ts +9 -0
  6. package/dist/commands/_registry.d.ts.map +1 -0
  7. package/dist/commands/_registry.js +11 -0
  8. package/dist/commands/_registry.js.map +1 -0
  9. package/dist/core/hooks.d.ts +5 -0
  10. package/dist/core/hooks.d.ts.map +1 -0
  11. package/dist/core/hooks.js +13 -0
  12. package/dist/core/hooks.js.map +1 -0
  13. package/dist/core/router.d.ts +4 -0
  14. package/dist/core/router.d.ts.map +1 -0
  15. package/dist/core/router.js +13 -0
  16. package/dist/core/router.js.map +1 -0
  17. package/dist/core/session.d.ts +10 -0
  18. package/dist/core/session.d.ts.map +1 -0
  19. package/dist/core/session.js +12 -0
  20. package/dist/core/session.js.map +1 -0
  21. package/dist/core/tool-runner.d.ts +4 -0
  22. package/dist/core/tool-runner.d.ts.map +1 -0
  23. package/dist/core/tool-runner.js +11 -0
  24. package/dist/core/tool-runner.js.map +1 -0
  25. package/dist/mcps/_registry.d.ts +8 -0
  26. package/dist/mcps/_registry.d.ts.map +1 -0
  27. package/dist/mcps/_registry.js +12 -0
  28. package/dist/mcps/_registry.js.map +1 -0
  29. package/dist/mcps/newrelic/prompts/commerce.d.ts +2 -0
  30. package/dist/mcps/newrelic/prompts/commerce.d.ts.map +1 -0
  31. package/dist/mcps/newrelic/prompts/commerce.js +77 -0
  32. package/dist/mcps/newrelic/prompts/commerce.js.map +1 -0
  33. package/dist/mcps/newrelic/prompts/security.d.ts +2 -0
  34. package/dist/mcps/newrelic/prompts/security.d.ts.map +1 -0
  35. package/dist/mcps/newrelic/prompts/security.js +67 -0
  36. package/dist/mcps/newrelic/prompts/security.js.map +1 -0
  37. package/dist/mcps/newrelic/queries.d.ts +3 -0
  38. package/dist/mcps/newrelic/queries.d.ts.map +1 -0
  39. package/dist/mcps/newrelic/queries.js +32 -0
  40. package/dist/mcps/newrelic/queries.js.map +1 -0
  41. package/dist/mcps/newrelic/server.d.ts +3 -0
  42. package/dist/mcps/newrelic/server.d.ts.map +1 -0
  43. package/dist/mcps/newrelic/server.js +88 -0
  44. package/dist/mcps/newrelic/server.js.map +1 -0
  45. package/dist/mcps/newrelic/tools.d.ts +8 -0
  46. package/dist/mcps/newrelic/tools.d.ts.map +1 -0
  47. package/dist/mcps/newrelic/tools.js +101 -0
  48. package/dist/mcps/newrelic/tools.js.map +1 -0
  49. package/dist/mcps/newrelic/types.d.ts +17 -0
  50. package/dist/mcps/newrelic/types.d.ts.map +1 -0
  51. package/dist/mcps/newrelic/types.js +2 -0
  52. package/dist/mcps/newrelic/types.js.map +1 -0
  53. package/dist/providers/_base/agent.d.ts +15 -0
  54. package/dist/providers/_base/agent.d.ts.map +1 -0
  55. package/dist/providers/_base/agent.js +2 -0
  56. package/dist/providers/_base/agent.js.map +1 -0
  57. package/dist/providers/_base/provider.d.ts +6 -0
  58. package/dist/providers/_base/provider.d.ts.map +1 -0
  59. package/dist/providers/_base/provider.js +2 -0
  60. package/dist/providers/_base/provider.js.map +1 -0
  61. package/dist/providers/_base/types.d.ts +43 -0
  62. package/dist/providers/_base/types.d.ts.map +1 -0
  63. package/dist/providers/_base/types.js +2 -0
  64. package/dist/providers/_base/types.js.map +1 -0
  65. package/dist/skills/_loader.d.ts +9 -0
  66. package/dist/skills/_loader.d.ts.map +1 -0
  67. package/dist/skills/_loader.js +11 -0
  68. package/dist/skills/_loader.js.map +1 -0
  69. package/package.json +30 -0
@@ -0,0 +1,10 @@
1
+ import type { AgentConfig, IAgent } from '../providers/_base/agent.js';
2
+ import type { IProvider } from '../providers/_base/provider.js';
3
+ import type { Message } from '../providers/_base/types.js';
4
+ export declare abstract class BaseAgent implements IAgent {
5
+ readonly config: AgentConfig;
6
+ constructor(config: AgentConfig);
7
+ run(messages: Message[], provider: IProvider): Promise<Message[]>;
8
+ protected abstract handleToolCall(name: string, input: Record<string, unknown>): Promise<string>;
9
+ }
10
+ //# sourceMappingURL=_base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_base.d.ts","sourceRoot":"","sources":["../../agents/_base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,6BAA6B,CAAC;AAE3E,8BAAsB,SAAU,YAAW,MAAM;IACnC,QAAQ,CAAC,MAAM,EAAE,WAAW;gBAAnB,MAAM,EAAE,WAAW;IAElC,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAkCvE,SAAS,CAAC,QAAQ,CAAC,cAAc,CAC/B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC;CACnB"}
@@ -0,0 +1,30 @@
1
+ export class BaseAgent {
2
+ config;
3
+ constructor(config) {
4
+ this.config = config;
5
+ }
6
+ async run(messages, provider) {
7
+ const history = [...messages];
8
+ const maxIterations = this.config.maxIterations ?? 10;
9
+ for (let i = 0; i < maxIterations; i++) {
10
+ const result = await provider.generate({
11
+ model: this.config.model,
12
+ messages: history,
13
+ tools: this.config.tools,
14
+ system: this.config.systemPrompt,
15
+ });
16
+ history.push({ role: 'assistant', content: result.content });
17
+ if (result.stopReason !== 'tool_use')
18
+ break;
19
+ const toolUses = result.content.filter((c) => c.type === 'tool_use');
20
+ const toolResults = await Promise.all(toolUses.map(async (tu) => ({
21
+ type: 'tool_result',
22
+ tool_use_id: tu.id,
23
+ content: await this.handleToolCall(tu.name, tu.input),
24
+ })));
25
+ history.push({ role: 'user', content: toolResults });
26
+ }
27
+ return history;
28
+ }
29
+ }
30
+ //# sourceMappingURL=_base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_base.js","sourceRoot":"","sources":["../../agents/_base.ts"],"names":[],"mappings":"AAIA,MAAM,OAAgB,SAAS;IACR;IAArB,YAAqB,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAE5C,KAAK,CAAC,GAAG,CAAC,QAAmB,EAAE,QAAmB;QAChD,MAAM,OAAO,GAAc,CAAC,GAAG,QAAQ,CAAC,CAAC;QACzC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC;QAEtD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC;gBACrC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;gBACxB,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;gBACxB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;aACjC,CAAC,CAAC;YAEH,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YAE7D,IAAI,MAAM,CAAC,UAAU,KAAK,UAAU;gBAAE,MAAM;YAE5C,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CACpC,CAAC,CAAC,EAAuB,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAClD,CAAC;YAEF,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CACnC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;gBAC1B,IAAI,EAAE,aAAsB;gBAC5B,WAAW,EAAE,EAAE,CAAC,EAAE;gBAClB,OAAO,EAAE,MAAM,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC;aACtD,CAAC,CAAC,CACJ,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;QACvD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CAMF"}
@@ -0,0 +1,9 @@
1
+ export interface Command {
2
+ name: string;
3
+ description: string;
4
+ run(args: string[]): Promise<void>;
5
+ }
6
+ export declare function registerCommand(command: Command): void;
7
+ export declare function getCommand(name: string): Command | undefined;
8
+ export declare function listCommands(): Command[];
9
+ //# sourceMappingURL=_registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_registry.d.ts","sourceRoot":"","sources":["../../commands/_registry.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAID,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEtD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAE5D;AAED,wBAAgB,YAAY,IAAI,OAAO,EAAE,CAExC"}
@@ -0,0 +1,11 @@
1
+ const registry = new Map();
2
+ export function registerCommand(command) {
3
+ registry.set(command.name, command);
4
+ }
5
+ export function getCommand(name) {
6
+ return registry.get(name);
7
+ }
8
+ export function listCommands() {
9
+ return Array.from(registry.values());
10
+ }
11
+ //# sourceMappingURL=_registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_registry.js","sourceRoot":"","sources":["../../commands/_registry.ts"],"names":[],"mappings":"AAMA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;AAE5C,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export type HookEvent = 'before-tool' | 'after-tool' | 'before-generate' | 'after-generate';
2
+ export type HookHandler = (event: HookEvent, payload: unknown) => Promise<void>;
3
+ export declare function registerHook(event: HookEvent, handler: HookHandler): void;
4
+ export declare function emit(event: HookEvent, payload: unknown): Promise<void>;
5
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../core/hooks.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAC5F,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAIhF,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAIzE;AAED,wBAAsB,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAK5E"}
@@ -0,0 +1,13 @@
1
+ const hooks = new Map();
2
+ export function registerHook(event, handler) {
3
+ const list = hooks.get(event) ?? [];
4
+ list.push(handler);
5
+ hooks.set(event, list);
6
+ }
7
+ export async function emit(event, payload) {
8
+ const list = hooks.get(event) ?? [];
9
+ for (const handler of list) {
10
+ await handler(event, payload);
11
+ }
12
+ }
13
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../core/hooks.ts"],"names":[],"mappings":"AAGA,MAAM,KAAK,GAAG,IAAI,GAAG,EAA4B,CAAC;AAElD,MAAM,UAAU,YAAY,CAAC,KAAgB,EAAE,OAAoB;IACjE,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACpC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnB,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,KAAgB,EAAE,OAAgB;IAC3D,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACpC,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;QAC3B,MAAM,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { IProvider } from '../providers/_base/provider.js';
2
+ export declare function registerProvider(provider: IProvider): void;
3
+ export declare function resolveProvider(name?: string): IProvider;
4
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../core/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAIhE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAE1D;AAED,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CASxD"}
@@ -0,0 +1,13 @@
1
+ const providers = new Map();
2
+ export function registerProvider(provider) {
3
+ providers.set(provider.name, provider);
4
+ }
5
+ export function resolveProvider(name) {
6
+ const target = name ?? process.env.AI_PROVIDER ?? 'claude';
7
+ const provider = providers.get(target);
8
+ if (!provider) {
9
+ throw new Error(`Unknown provider "${target}". Registered: ${[...providers.keys()].join(', ')}`);
10
+ }
11
+ return provider;
12
+ }
13
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../core/router.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,IAAI,GAAG,EAAqB,CAAC;AAE/C,MAAM,UAAU,gBAAgB,CAAC,QAAmB;IAClD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,MAAM,MAAM,GAAG,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,QAAQ,CAAC;IAC3D,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,qBAAqB,MAAM,kBAAkB,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAChF,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Message } from '../providers/_base/types.js';
2
+ export interface Session {
3
+ id: string;
4
+ provider: string;
5
+ messages: Message[];
6
+ createdAt: Date;
7
+ }
8
+ export declare function createSession(provider: string): Session;
9
+ export declare function appendMessage(session: Session, message: Message): void;
10
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../core/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAE3D,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOvD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAEtE"}
@@ -0,0 +1,12 @@
1
+ export function createSession(provider) {
2
+ return {
3
+ id: crypto.randomUUID(),
4
+ provider,
5
+ messages: [],
6
+ createdAt: new Date(),
7
+ };
8
+ }
9
+ export function appendMessage(session, message) {
10
+ session.messages.push(message);
11
+ }
12
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../core/session.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,UAAU,EAAE;QACvB,QAAQ;QACR,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,IAAI,IAAI,EAAE;KACtB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAgB,EAAE,OAAgB;IAC9D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export type ToolHandler = (input: Record<string, unknown>) => Promise<string>;
2
+ export declare function registerTool(name: string, handler: ToolHandler): void;
3
+ export declare function runTool(name: string, input: Record<string, unknown>): Promise<string>;
4
+ //# sourceMappingURL=tool-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-runner.d.ts","sourceRoot":"","sources":["../../core/tool-runner.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAI9E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAErE;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAI3F"}
@@ -0,0 +1,11 @@
1
+ const handlers = new Map();
2
+ export function registerTool(name, handler) {
3
+ handlers.set(name, handler);
4
+ }
5
+ export async function runTool(name, input) {
6
+ const handler = handlers.get(name);
7
+ if (!handler)
8
+ throw new Error(`No handler registered for tool "${name}"`);
9
+ return handler(input);
10
+ }
11
+ //# sourceMappingURL=tool-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-runner.js","sourceRoot":"","sources":["../../core/tool-runner.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;AAEhD,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,OAAoB;IAC7D,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,KAA8B;IACxE,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,GAAG,CAAC,CAAC;IAC1E,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface McpServerEntry {
2
+ name: string;
3
+ command: string;
4
+ args?: string[];
5
+ env?: Record<string, string>;
6
+ }
7
+ export declare const mcpRegistry: Record<string, McpServerEntry>;
8
+ //# sourceMappingURL=_registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_registry.d.ts","sourceRoot":"","sources":["../../mcps/_registry.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAUtD,CAAC"}
@@ -0,0 +1,12 @@
1
+ export const mcpRegistry = {
2
+ newrelic: {
3
+ name: 'newrelic-nrql',
4
+ command: 'node',
5
+ args: ['dist/mcps/newrelic/server.js'],
6
+ env: {
7
+ NEW_RELIC_API_KEY: process.env.NEW_RELIC_API_KEY ?? '',
8
+ NEW_RELIC_REGION: process.env.NEW_RELIC_REGION ?? 'us',
9
+ },
10
+ },
11
+ };
12
+ //# sourceMappingURL=_registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_registry.js","sourceRoot":"","sources":["../../mcps/_registry.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,WAAW,GAAmC;IACzD,QAAQ,EAAE;QACR,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,CAAC,8BAA8B,CAAC;QACtC,GAAG,EAAE;YACH,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE;YACtD,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,IAAI;SACvD;KACF;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const commercePrompt: string;
2
+ //# sourceMappingURL=commerce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commerce.d.ts","sourceRoot":"","sources":["../../../../mcps/newrelic/prompts/commerce.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,QA2EnB,CAAC"}
@@ -0,0 +1,77 @@
1
+ export const commercePrompt = `
2
+ You are a New Relic specialist. You run NRQL queries and resolve Adobe Commerce project IDs to account IDs using the New Relic MCP tools.
3
+
4
+ **Critical:** Do not use any attribute name in NRQL unless it was returned by a \`SELECT * FROM <entity> ... LIMIT 1\` query you already ran for that entity. Run that discovery query first; then use only the keys from the result. Never guess or invent field names.
5
+
6
+ ## When invoked
7
+
8
+ 1. **If the user provides an Adobe Commerce project ID** (and no account ID):
9
+ - Call the New Relic MCP tool \`get_account_id_by_project_id\` with that project ID.
10
+ - Use the returned \`accountId\` from the first matching entity for all NRQL execution.
11
+ - If no entities are found, tell the user and suggest checking the project ID or NEW_RELIC_API_KEY.
12
+
13
+ 2. **Before writing any NRQL that uses specific field names** (in SELECT, WHERE, FACET, etc.):
14
+ - You **must** first run \`SELECT * FROM <entity> ... LIMIT 1\` (with the correct WHERE for that entity and a SINCE clause).
15
+ - Inspect the JSON result and note the **exact attribute names** (keys) returned.
16
+ - **Only use those attribute names** in subsequent queries. Do not assume, guess, or invent field names.
17
+
18
+ 3. **Build NRQL** from the user's intent and the standard Adobe Commerce patterns below. Use the project ID in filters as shown. For any non-\`SELECT *\` query, use only fields you obtained in step 2.
19
+
20
+ 4. **Execute NRQL** with the MCP tool \`execute_nrql\`, passing the \`account_id\` from step 1 (or the user's account ID if they provided it). Use a sensible \`timeout_seconds\` (e.g. 30) for large result sets.
21
+
22
+ 5. **Summarize results** clearly: row count, key fields, and any errors or empty result sets.
23
+
24
+ ## Entity → query pattern (Adobe Commerce)
25
+
26
+ The filter depends on the **entity** (NRQL FROM clause). Use this mapping:
27
+
28
+ | Entity | Filter | Example |
29
+ |--------|--------|---------|
30
+ | **Log** | \`apmApplicationNames = '\\|<project id>\\|'\` | \`SELECT * FROM Log WHERE apmApplicationNames = '\\|<project id>\\|' SINCE 1 day ago\` |
31
+ | **Log (Fastly)** | \`cache_status IS NOT NULL AND project_id = '<project id>'\` | \`SELECT * FROM Log WHERE cache_status IS NOT NULL AND project_id = '<project id>' SINCE 1 day ago\` |
32
+ | **ProcessSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | \`SELECT * FROM ProcessSample WHERE apmApplicationNames = '\\|<project id>\\|'\` |
33
+ | **NetworkSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
34
+ | **StorageSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
35
+ | **SystemSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
36
+ | **ElasticsearchClusterSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
37
+ | **ElasticsearchCommonSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
38
+ | **ElasticsearchIndexSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
39
+ | **ElasticsearchNodeSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
40
+ | **FlexRedisMemorySample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
41
+ | **MysqlSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
42
+ | **RabbitmqExchangeSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
43
+ | **RabbitmqNodeSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
44
+ | **RabbitmqQueueSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
45
+ | **RabbitmqVhostSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
46
+ | **RedisKeyspaceSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
47
+ | **RedisSample** | \`apmApplicationNames = '\\|<project id>\\|'\` | same pattern |
48
+ | **Transaction** | \`appName = '<project id>'\` | \`SELECT * FROM Transaction WHERE appName = '<project id>'\` |
49
+ | **TransactionError** | \`appName = '<project id>'\` | \`SELECT * FROM TransactionError WHERE appName = '<project id>'\` |
50
+ | **PageView** | \`appName = '<project id>'\` | \`SELECT * FROM PageView WHERE appName = '<project id>'\` |
51
+ | **PageViewTiming** | \`appName = '<project id>'\` | \`SELECT * FROM PageViewTiming WHERE appName = '<project id>'\` |
52
+ | **ErrorTrace** | \`appName = '<project id>'\` | \`SELECT * FROM ErrorTrace WHERE appName = '<project id>'\` |
53
+ | **TransactionTrace** | (no standard project filter) | Add WHERE by appName or other attributes as needed |
54
+ | **SqlTrace** | \`guid = '<guid>'\` | \`SELECT * FROM SqlTrace WHERE guid = '<guid>'\` (use transaction GUID) |
55
+
56
+ **Rules:**
57
+ - **apmApplicationNames:** use the literal pipe-delimited form \`'|<project id>|'\` (two pipe characters around the project id).
58
+ - **appName:** use \`'<project id>'\` with no pipes.
59
+ - **Log** time range: always add \`SINCE ...\` (e.g. \`SINCE 1 day ago\`) or \`SINCE <epoch_ms> UNTIL <epoch_ms>\` when the user gives a time window.
60
+ - Replace \`<project id>\` and \`<guid>\` with the actual values.
61
+
62
+ ## Discovering available fields (mandatory)
63
+
64
+ **You must not use any field name in NRQL unless it was returned by a prior \`SELECT *\` from that same entity.**
65
+
66
+ 1. Run exactly: \`SELECT * FROM <entity> [WHERE ... per entity table] LIMIT 1 SINCE 1 hour ago\`
67
+ 2. Look at the JSON result: the top-level keys in each result object are the **only valid attribute names** for that entity.
68
+ 3. Use **only those keys** in later queries. If the user asks for a field not in the result, say it was not found and list available fields.
69
+
70
+ ## General NRQL
71
+
72
+ - If the user asks for a custom NRQL query (no project ID), use \`execute_nrql\` with either the account ID from \`get_account_id_by_project_id\` or \`NEW_RELIC_ACCOUNT_ID\` / an explicitly given account ID.
73
+ - Use standard NRQL time clauses: \`SINCE 1 hour ago\`, \`SINCE 1 day ago\`, or \`SINCE <epoch_ms> UNTIL <epoch_ms>\` when appropriate.
74
+ - Prefer \`LIMIT\` (e.g. \`LIMIT 100\`) in exploratory queries to avoid huge payloads.
75
+ - If NerdGraph or the MCP returns an error, surface it to the user and suggest fixes (e.g. check API key, account ID, or query syntax).
76
+ `.trim();
77
+ //# sourceMappingURL=commerce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commerce.js","sourceRoot":"","sources":["../../../../mcps/newrelic/prompts/commerce.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2E7B,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const securityPrompt: string;
2
+ //# sourceMappingURL=security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../../mcps/newrelic/prompts/security.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,QAgEnB,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { commercePrompt } from './commerce.js';
2
+ export const securityPrompt = `${commercePrompt}
3
+
4
+ ---
5
+
6
+ ## Security & Attack Analysis
7
+
8
+ You are also a security analyst. In addition to the general NRQL and Adobe Commerce capabilities above, you detect and investigate attacks against Adobe Commerce projects using New Relic data.
9
+
10
+ ### Attack categories to investigate
11
+
12
+ | Category | Primary entities | Key signals |
13
+ |----------|-----------------|-------------|
14
+ | **Brute force / credential stuffing** | Log, Transaction, TransactionError | High rate of 401/403 responses, repeated login endpoint hits from same IP |
15
+ | **SQL injection** | Log, TransactionError, ErrorTrace | Query errors, \`sql_error\` fields, suspicious SQL fragments in request URLs or bodies |
16
+ | **XSS / injection** | Log, TransactionError | Script tags or encoded payloads in request parameters, error messages referencing DOM injection |
17
+ | **DDoS / traffic flood** | Log (Fastly), Transaction, SystemSample | Sudden spike in request rate, high \`cache_status = MISS\` ratio, CPU/memory saturation |
18
+ | **Web scraping / bot traffic** | Log (Fastly), PageView | Abnormal request volume from single IP, non-browser user agents, high catalogue-page hit rate |
19
+ | **Path traversal / LFI** | Log, TransactionError | \`../\` sequences or \`/etc/passwd\` patterns in request URIs |
20
+ | **Admin panel probing** | Log, Transaction | Repeated 404/403 on \`/admin\`, \`/wp-admin\`, \`/phpmyadmin\` or similar paths |
21
+ | **Carding / payment abuse** | Transaction, TransactionError | High rate of checkout or payment-endpoint failures from few IPs |
22
+ | **API abuse** | Transaction, Log | Unusually high API call rate, repeated calls to sensitive endpoints |
23
+
24
+ ### Investigation workflow
25
+
26
+ 1. **Resolve account** — same as the base prompt: call \`get_account_id_by_project_id\` if only a project ID is given.
27
+
28
+ 2. **Discover fields** — run \`SELECT * FROM <entity> WHERE <filter> LIMIT 1 SINCE 1 hour ago\` for each entity you plan to query. Only use field names from those results.
29
+
30
+ 3. **Choose the right entity and time window**:
31
+ - For HTTP-level attacks (IPs, paths, status codes, user agents) start with **Fastly logs** (\`cache_status IS NOT NULL AND project_id = '<project id>'\`).
32
+ - For application-level errors/exceptions use **TransactionError** and **ErrorTrace**.
33
+ - For infrastructure stress (CPU, memory) use **SystemSample** / **ProcessSample**.
34
+ - Default time window: \`SINCE 1 hour ago\` for active incidents; \`SINCE 1 day ago\` for historical review.
35
+
36
+ 4. **Detect attack patterns** — use aggregation queries like:
37
+ \`\`\`
38
+ SELECT count(*) FROM Log WHERE cache_status IS NOT NULL AND project_id = '<project id>'
39
+ FACET <ip_field> SINCE 1 hour ago LIMIT 20
40
+
41
+ SELECT count(*) FROM Log WHERE cache_status IS NOT NULL AND project_id = '<project id>'
42
+ FACET <status_field> SINCE 1 hour ago TIMESERIES 5 minutes
43
+
44
+ SELECT count(*) FROM Transaction WHERE appName = '<project id>'
45
+ AND <request_uri_field> LIKE '%/customer/account/loginPost%'
46
+ FACET <client_ip_field> SINCE 1 hour ago LIMIT 20
47
+
48
+ SELECT count(*) FROM TransactionError WHERE appName = '<project id>'
49
+ TIMESERIES 5 minutes SINCE 1 hour ago
50
+ \`\`\`
51
+ Replace bracketed field names with those discovered in step 2.
52
+
53
+ 5. **Summarise findings** — report:
54
+ - Attack type (if identifiable) and confidence level.
55
+ - Top offending IPs / user agents.
56
+ - Affected endpoints or resources.
57
+ - Volume and time range of the anomaly.
58
+ - Recommended mitigation (e.g. rate-limit, block IP at CDN, WAF rule).
59
+
60
+ ### Rules specific to security analysis
61
+
62
+ - **Never expose raw API keys, tokens, or passwords** found in log results. Redact them as \`[REDACTED]\` before displaying.
63
+ - **Do not fabricate field names** — always run the \`SELECT * LIMIT 1\` discovery query first.
64
+ - When evidence is ambiguous, state it clearly and suggest additional queries rather than asserting an attack occurred.
65
+ - If the user asks to block an IP or apply a WAF rule, note that those actions must be taken outside New Relic (e.g. in the Fastly or CDN console) and are not performed by this tool.
66
+ `.trim();
67
+ //# sourceMappingURL=security.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security.js","sourceRoot":"","sources":["../../../../mcps/newrelic/prompts/security.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgE9C,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const NRQL_SINGLE_ACCOUNT_QUERY = "\n query NrqlSingleAccount($accountId: Int!, $nrql: Nrql!) {\n actor {\n account(id: $accountId) {\n nrql(query: $nrql) {\n results\n }\n }\n }\n }\n";
2
+ export declare const ENTITY_SEARCH_QUERY = "\n query EntitySearch($searchQuery: String!) {\n actor {\n entitySearch(query: $searchQuery) {\n query\n results {\n entities {\n accountId\n guid\n name\n tags {\n key\n values\n }\n }\n }\n }\n }\n }\n";
3
+ //# sourceMappingURL=queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../mcps/newrelic/queries.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,mMAUrC,CAAC;AAEF,eAAO,MAAM,mBAAmB,0VAmB/B,CAAC"}
@@ -0,0 +1,32 @@
1
+ export const NRQL_SINGLE_ACCOUNT_QUERY = `
2
+ query NrqlSingleAccount($accountId: Int!, $nrql: Nrql!) {
3
+ actor {
4
+ account(id: $accountId) {
5
+ nrql(query: $nrql) {
6
+ results
7
+ }
8
+ }
9
+ }
10
+ }
11
+ `;
12
+ export const ENTITY_SEARCH_QUERY = `
13
+ query EntitySearch($searchQuery: String!) {
14
+ actor {
15
+ entitySearch(query: $searchQuery) {
16
+ query
17
+ results {
18
+ entities {
19
+ accountId
20
+ guid
21
+ name
22
+ tags {
23
+ key
24
+ values
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
31
+ `;
32
+ //# sourceMappingURL=queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../mcps/newrelic/queries.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;;CAUxC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;CAmBlC,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import 'dotenv/config';
3
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../mcps/newrelic/server.ts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC"}
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+ import 'dotenv/config';
3
+ import * as z from 'zod/v4';
4
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
6
+ import { commercePrompt } from './prompts/commerce.js';
7
+ import { securityPrompt } from './prompts/security.js';
8
+ import { ensureApiKey, getApiKey, getDefaultAccountId, runExecuteNrql, runGetAccountIdByProjectId, } from './tools.js';
9
+ const server = new McpServer({ name: 'newrelic-nrql', version: '0.1.0' }, { instructions: 'Execute NRQL queries against New Relic via NerdGraph.' });
10
+ server.registerPrompt('newrelic_commerce', {
11
+ description: 'New Relic NRQL specialist for Adobe Commerce and general querying. Resolves project IDs to account IDs and runs NRQL queries.',
12
+ argsSchema: {
13
+ project_id: z.string().optional().describe('Adobe Commerce project ID to pre-fill in the prompt'),
14
+ },
15
+ }, ({ project_id }) => ({
16
+ messages: [
17
+ {
18
+ role: 'user',
19
+ content: {
20
+ type: 'text',
21
+ text: project_id ? commercePrompt.replace(/<project id>/g, project_id) : commercePrompt,
22
+ },
23
+ },
24
+ ],
25
+ }));
26
+ server.registerPrompt('newrelic_security', {
27
+ description: 'New Relic security analyst for Adobe Commerce. Detects and investigates attacks (brute force, SQLi, XSS, DDoS, scraping, etc.) using NRQL queries.',
28
+ argsSchema: {
29
+ project_id: z.string().optional().describe('Adobe Commerce project ID to pre-fill in the prompt'),
30
+ },
31
+ }, ({ project_id }) => ({
32
+ messages: [
33
+ {
34
+ role: 'user',
35
+ content: {
36
+ type: 'text',
37
+ text: project_id ? securityPrompt.replace(/<project id>/g, project_id) : securityPrompt,
38
+ },
39
+ },
40
+ ],
41
+ }));
42
+ server.registerTool('execute_nrql', {
43
+ title: 'Execute NRQL Query',
44
+ description: 'Run a NRQL query against a New Relic account via NerdGraph.',
45
+ inputSchema: z.object({
46
+ query: z.string().min(1).describe('The NRQL query to execute'),
47
+ account_id: z
48
+ .number()
49
+ .int()
50
+ .optional()
51
+ .describe('New Relic account ID (uses NEW_RELIC_ACCOUNT_ID env var if omitted)'),
52
+ timeout_seconds: z
53
+ .number()
54
+ .int()
55
+ .min(1)
56
+ .max(70)
57
+ .optional()
58
+ .describe('Request timeout in seconds (default 30)'),
59
+ }),
60
+ }, async ({ query, account_id, timeout_seconds }) => {
61
+ const resolvedAccountId = account_id ?? getDefaultAccountId();
62
+ if (resolvedAccountId === null) {
63
+ throw new Error('account_id is required. Pass it to this tool or set NEW_RELIC_ACCOUNT_ID in the environment.');
64
+ }
65
+ const text = await runExecuteNrql(query, resolvedAccountId, timeout_seconds ?? 30);
66
+ return { content: [{ type: 'text', text }] };
67
+ });
68
+ server.registerTool('get_account_id_by_project_id', {
69
+ title: 'Get Account ID by Project ID',
70
+ description: 'Look up a New Relic account ID for an Adobe Commerce project ID via entity search.',
71
+ inputSchema: z.object({
72
+ project_id: z.string().min(1).describe('Adobe Commerce project ID'),
73
+ }),
74
+ }, async ({ project_id }) => {
75
+ const text = await runGetAccountIdByProjectId(project_id);
76
+ return { content: [{ type: 'text', text }] };
77
+ });
78
+ async function main() {
79
+ ensureApiKey(getApiKey());
80
+ const transport = new StdioServerTransport();
81
+ await server.connect(transport);
82
+ console.error('New Relic MCP server running on stdio');
83
+ }
84
+ main().catch((error) => {
85
+ console.error('Fatal error in main():', error);
86
+ process.exit(1);
87
+ });
88
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../mcps/newrelic/server.ts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC;AACvB,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,cAAc,EACd,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,EAC3C,EAAE,YAAY,EAAE,uDAAuD,EAAE,CAC1E,CAAC;AAEF,MAAM,CAAC,cAAc,CACnB,mBAAmB,EACnB;IACE,WAAW,EACT,+H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;IAC1B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;AACzD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare function getApiKey(): string;
2
+ export declare function getBaseUrl(): string;
3
+ export declare function getDefaultAccountId(): number | null;
4
+ export declare function ensureApiKey(apiKey: string): void;
5
+ export declare function executeNerdgraph(query: string, variables: Record<string, unknown>, timeoutSeconds?: number): Promise<Record<string, unknown>>;
6
+ export declare function runExecuteNrql(query: string, accountId: number, timeoutSeconds: number): Promise<string>;
7
+ export declare function runGetAccountIdByProjectId(projectId: string): Promise<string>;
8
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../mcps/newrelic/tools.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAGnC;AAED,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAKnD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAMjD;AAED,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,cAAc,GAAE,MAAgC,GAC/C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA8ClC;AAoBD,wBAAsB,cAAc,CAClC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED,wBAAsB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgCnF"}
@@ -0,0 +1,101 @@
1
+ import { ENTITY_SEARCH_QUERY, NRQL_SINGLE_ACCOUNT_QUERY } from './queries.js';
2
+ const GRAPHQL_URL_US = 'https://api.newrelic.com/graphql';
3
+ const GRAPHQL_URL_EU = 'https://api.eu.newrelic.com/graphql';
4
+ const DEFAULT_TIMEOUT_SECONDS = 60;
5
+ export function getApiKey() {
6
+ return (process.env.NEW_RELIC_API_KEY ?? '').trim();
7
+ }
8
+ export function getBaseUrl() {
9
+ const region = (process.env.NEW_RELIC_REGION ?? 'us').trim().toLowerCase();
10
+ return region === 'eu' ? GRAPHQL_URL_EU : GRAPHQL_URL_US;
11
+ }
12
+ export function getDefaultAccountId() {
13
+ const str = (process.env.NEW_RELIC_ACCOUNT_ID ?? '').trim();
14
+ if (!str)
15
+ return null;
16
+ const parsed = Number.parseInt(str, 10);
17
+ return Number.isNaN(parsed) ? null : parsed;
18
+ }
19
+ export function ensureApiKey(apiKey) {
20
+ if (!apiKey) {
21
+ throw new Error('NEW_RELIC_API_KEY is not set. Set it in the environment or .env before running the server.');
22
+ }
23
+ }
24
+ export async function executeNerdgraph(query, variables, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
25
+ const apiKey = getApiKey();
26
+ ensureApiKey(apiKey);
27
+ const controller = new AbortController();
28
+ const timer = setTimeout(() => controller.abort(), Math.max(1, timeoutSeconds) * 1000);
29
+ try {
30
+ const response = await fetch(getBaseUrl(), {
31
+ method: 'POST',
32
+ headers: {
33
+ 'Content-Type': 'application/json',
34
+ 'API-Key': apiKey,
35
+ },
36
+ body: JSON.stringify({ query, variables }),
37
+ signal: controller.signal,
38
+ });
39
+ const body = (await response.json());
40
+ if (response.status !== 200) {
41
+ const message = typeof body.message === 'string'
42
+ ? body.message
43
+ : typeof body.error === 'string'
44
+ ? body.error
45
+ : JSON.stringify(body);
46
+ throw new Error(`NerdGraph request failed (HTTP ${response.status}): ${message}`);
47
+ }
48
+ const errors = body.errors;
49
+ if (Array.isArray(errors) && errors.length > 0) {
50
+ const messages = errors
51
+ .map((e) => typeof e === 'object' && e !== null && 'message' in e
52
+ ? String(e.message ?? JSON.stringify(e))
53
+ : JSON.stringify(e))
54
+ .join('; ');
55
+ throw new Error(`NerdGraph returned errors: ${messages}`);
56
+ }
57
+ return body;
58
+ }
59
+ finally {
60
+ clearTimeout(timer);
61
+ }
62
+ }
63
+ function extractNrqlResults(data) {
64
+ const actor = data.data?.actor;
65
+ const account = actor?.account;
66
+ const nrql = account?.nrql;
67
+ return Array.isArray(nrql?.results) ? nrql.results : [];
68
+ }
69
+ function extractEntitySearchEntities(data) {
70
+ const actor = data.data?.actor;
71
+ const entitySearch = actor?.entitySearch;
72
+ const results = entitySearch?.results;
73
+ return Array.isArray(results?.entities) ? results.entities : [];
74
+ }
75
+ export async function runExecuteNrql(query, accountId, timeoutSeconds) {
76
+ const body = await executeNerdgraph(NRQL_SINGLE_ACCOUNT_QUERY, { accountId, nrql: query.trim() }, timeoutSeconds);
77
+ return JSON.stringify(extractNrqlResults(body), null, 2);
78
+ }
79
+ export async function runGetAccountIdByProjectId(projectId) {
80
+ const trimmedId = projectId.trim();
81
+ if (!trimmedId)
82
+ throw new Error('project_id is required and must be non-empty.');
83
+ const safeId = trimmedId.replace(/'/g, "\\'");
84
+ const searchQuery = `tags.account LIKE '%${safeId}%' AND domain = 'APM' AND name = '${safeId}'`;
85
+ const body = await executeNerdgraph(ENTITY_SEARCH_QUERY, { searchQuery }, 30);
86
+ const entities = extractEntitySearchEntities(body);
87
+ if (entities.length === 0) {
88
+ return JSON.stringify({ found: false, message: `No entities found for project_id: ${trimmedId}`, entities: [] }, null, 2);
89
+ }
90
+ return JSON.stringify({
91
+ found: true,
92
+ count: entities.length,
93
+ entities: entities.map((e) => ({
94
+ accountId: e.accountId,
95
+ guid: e.guid,
96
+ name: e.name,
97
+ tags: e.tags,
98
+ })),
99
+ }, null, 2);
100
+ }
101
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../mcps/newrelic/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAE9E,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAC1D,MAAM,cAAc,GAAG,qCAAqC,CAAC;AAC7D,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,MAAM,UAAU,SAAS;IACvB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3E,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5D,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,M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,QAAQ,CAAC,MAAM;QACtB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI;SACb,CAAC,CAAC;KACJ,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ export interface Tag {
2
+ key: string;
3
+ values: string[];
4
+ }
5
+ export interface Entity {
6
+ accountId: number;
7
+ guid: string;
8
+ name: string;
9
+ tags: Tag[];
10
+ }
11
+ export interface EntitySearchResult {
12
+ found: boolean;
13
+ count?: number;
14
+ message?: string;
15
+ entities: Entity[];
16
+ }
17
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../mcps/newrelic/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,EAAE,CAAC;CACb;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../mcps/newrelic/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import type { IProvider } from './provider.js';
2
+ import type { Message, ToolDefinition } from './types.js';
3
+ export interface AgentConfig {
4
+ name: string;
5
+ description: string;
6
+ model: string;
7
+ systemPrompt: string;
8
+ tools?: ToolDefinition[];
9
+ maxIterations?: number;
10
+ }
11
+ export interface IAgent {
12
+ readonly config: AgentConfig;
13
+ run(messages: Message[], provider: IProvider): Promise<Message[]>;
14
+ }
15
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../providers/_base/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CACnE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../providers/_base/agent.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { GenerateOptions, GenerateResult } from './types.js';
2
+ export interface IProvider {
3
+ readonly name: string;
4
+ generate(options: GenerateOptions): Promise<GenerateResult>;
5
+ }
6
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../providers/_base/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC7D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../providers/_base/provider.ts"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ export type Role = 'user' | 'assistant' | 'system';
2
+ export interface TextContent {
3
+ type: 'text';
4
+ text: string;
5
+ }
6
+ export interface ToolUseContent {
7
+ type: 'tool_use';
8
+ id: string;
9
+ name: string;
10
+ input: Record<string, unknown>;
11
+ }
12
+ export interface ToolResultContent {
13
+ type: 'tool_result';
14
+ tool_use_id: string;
15
+ content: string;
16
+ }
17
+ export type MessageContent = TextContent | ToolUseContent | ToolResultContent;
18
+ export interface Message {
19
+ role: Role;
20
+ content: MessageContent | MessageContent[];
21
+ }
22
+ export interface ToolDefinition {
23
+ name: string;
24
+ description: string;
25
+ inputSchema: Record<string, unknown>;
26
+ }
27
+ export interface GenerateOptions {
28
+ model: string;
29
+ messages: Message[];
30
+ tools?: ToolDefinition[];
31
+ system?: string;
32
+ maxTokens?: number;
33
+ temperature?: number;
34
+ }
35
+ export interface GenerateResult {
36
+ content: MessageContent[];
37
+ stopReason: 'end_turn' | 'tool_use' | 'max_tokens' | string;
38
+ usage: {
39
+ inputTokens: number;
40
+ outputTokens: number;
41
+ };
42
+ }
43
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../providers/_base/types.ts"],"names":[],"mapp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,CAAC;KACtB,CAAC;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../providers/_base/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ export interface Skill {
2
+ name: string;
3
+ description: string;
4
+ invoke(args: string): Promise<string>;
5
+ }
6
+ export declare function registerSkill(skill: Skill): void;
7
+ export declare function getSkill(name: string): Skill | undefined;
8
+ export declare function listSkills(): Skill[];
9
+ //# sourceMappingURL=_loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_loader.d.ts","sourceRoot":"","sources":["../../skills/_loader.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvC;AAID,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAEhD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAExD;AAED,wBAAgB,UAAU,IAAI,KAAK,EAAE,CAEpC"}
@@ -0,0 +1,11 @@
1
+ const registry = new Map();
2
+ export function registerSkill(skill) {
3
+ registry.set(skill.name, skill);
4
+ }
5
+ export function getSkill(name) {
6
+ return registry.get(name);
7
+ }
8
+ export function listSkills() {
9
+ return Array.from(registry.values());
10
+ }
11
+ //# sourceMappingURL=_loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_loader.js","sourceRoot":"","sources":["../../skills/_loader.ts"],"names":[],"mappings":"AAMA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAiB,CAAC;AAE1C,MAAM,UAAU,aAAa,CAAC,KAAY;IACxC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@kavinga/commerce-tools",
3
+ "version": "0.1.0",
4
+ "description": "Multi-provider AI tooling platform with MCPs, agents, skills, and commands",
5
+ "type": "module",
6
+ "bin": {
7
+ "newrelic-mcp": "./dist/mcps/newrelic/server.js"
8
+ },
9
+ "files": [
10
+ "dist/"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "dev:newrelic": "tsx mcps/newrelic/server.ts",
15
+ "start:newrelic": "node dist/mcps/newrelic/server.js"
16
+ },
17
+ "dependencies": {
18
+ "@modelcontextprotocol/sdk": "^1.27.1",
19
+ "dotenv": "^16.4.5",
20
+ "zod": "^3.25.76"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^22.7.4",
24
+ "tsx": "^4.19.1",
25
+ "typescript": "^5.6.3"
26
+ },
27
+ "engines": {
28
+ "node": ">=18"
29
+ }
30
+ }