Skip to content
Open
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
20 changes: 12 additions & 8 deletions src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import {
FEATURE_REF_REGEX,
REQUIREMENT_REF_REGEX,
NOTE_REF_REGEX,
EPIC_REF_REGEX,
Record,
FeatureResponse,
RequirementResponse,
EpicResponse,
PageResponse,
SearchResponse,
} from "./types.js";
import {
getFeatureQuery,
getRequirementQuery,
getEpicQuery,
getPageQuery,
searchDocumentsQuery,
} from "./queries.js";
Expand All @@ -36,9 +39,7 @@ export class Handlers {
if (FEATURE_REF_REGEX.test(reference)) {
const data = await this.client.request<FeatureResponse>(
getFeatureQuery,
{
id: reference,
}
{ id: reference }
);
result = data.feature;
} else if (REQUIREMENT_REF_REGEX.test(reference)) {
Expand All @@ -47,10 +48,16 @@ export class Handlers {
{ id: reference }
);
result = data.requirement;
} else if (EPIC_REF_REGEX.test(reference)) {
const data = await this.client.request<EpicResponse>(
getEpicQuery,
{ id: reference }
);
result = data.epic;
} else {
throw new McpError(
ErrorCode.InvalidParams,
"Invalid reference number format. Expected DEVELOP-123 or ADT-123-1"
"Invalid reference number format. Expected DEVELOP-123, ADT-123-1, or DCOMMS-E-157"
);
}

Expand All @@ -77,7 +84,6 @@ export class Handlers {
if (error instanceof McpError) {
throw error;
}

const errorMessage =
error instanceof Error ? error.message : String(error);
console.error("API Error:", errorMessage);
Expand Down Expand Up @@ -137,7 +143,6 @@ export class Handlers {
if (error instanceof McpError) {
throw error;
}

const errorMessage =
error instanceof Error ? error.message : String(error);
console.error("API Error:", errorMessage);
Expand Down Expand Up @@ -179,7 +184,6 @@ export class Handlers {
if (error instanceof McpError) {
throw error;
}

const errorMessage =
error instanceof Error ? error.message : String(error);
console.error("API Error:", errorMessage);
Expand All @@ -189,4 +193,4 @@ export class Handlers {
);
}
}
}
}
11 changes: 7 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node

import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
Expand Down Expand Up @@ -62,14 +63,15 @@ class AhaMcp {
tools: [
{
name: "get_record",
description: "Get an Aha! feature or requirement by reference number",
description:
"Get an Aha! feature, requirement, or epic by reference number",
inputSchema: {
type: "object",
properties: {
reference: {
type: "string",
description:
"Reference number (e.g., DEVELOP-123 or ADT-123-1)",
"Reference number (e.g., DEVELOP-123, ADT-123-1, or DCOMMS-E-157)",
},
},
required: ["reference"],
Expand Down Expand Up @@ -107,7 +109,8 @@ class AhaMcp {
},
searchableType: {
type: "string",
description: "Type of document to search for (e.g., Page)",
description:
"Type of document to search for (e.g., Page, Epic, Feature)",
default: "Page",
},
},
Expand Down Expand Up @@ -141,4 +144,4 @@ class AhaMcp {
}

const server = new AhaMcp();
server.run().catch(console.error);
server.run().catch(console.error);
87 changes: 49 additions & 38 deletions src/queries.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,68 @@
export const getPageQuery = `
query GetPage($id: ID!, $includeParent: Boolean!) {
page(id: $id) {
query GetPage($id: ID!, $includeParent: Boolean!) {
page(id: $id) {
name
description {
markdownBody
}
children {
name
referenceNum
}
parent @include(if: $includeParent) {
name
description {
markdownBody
}
children {
name
referenceNum
}
parent @include(if: $includeParent) {
name
referenceNum
}
referenceNum
}
}
}
`;

export const getFeatureQuery = `
query GetFeature($id: ID!) {
feature(id: $id) {
name
description {
markdownBody
}
query GetFeature($id: ID!) {
feature(id: $id) {
name
description {
markdownBody
}
}
}
`;

export const getRequirementQuery = `
query GetRequirement($id: ID!) {
requirement(id: $id) {
name
description {
markdownBody
}
query GetRequirement($id: ID!) {
requirement(id: $id) {
name
description {
markdownBody
}
}
}
`;

export const searchDocumentsQuery = `
query SearchDocuments($query: String!, $searchableType: [String!]!) {
searchDocuments(filters: {query: $query, searchableType: $searchableType}) {
nodes {
name
url
searchableId
searchableType
}
currentPage
totalCount
totalPages
isLastPage
export const getEpicQuery = `
query GetEpic($id: ID!) {
epic(id: $id) {
name
description {
markdownBody
}
}
}
`;

export const searchDocumentsQuery = `
query SearchDocuments($query: String!, $searchableType: [String!]!) {
searchDocuments(filters: {query: $query, searchableType: $searchableType}) {
nodes {
name
url
searchableId
searchableType
}
currentPage
totalCount
totalPages
isLastPage
}
}
`;
7 changes: 6 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export interface RequirementResponse {
requirement: Record;
}

export interface EpicResponse {
epic: Record;
}

export interface PageResponse {
page: {
name: string;
Expand All @@ -34,6 +38,7 @@ export interface PageResponse {
export const FEATURE_REF_REGEX = /^([A-Z][A-Z0-9]*)-(\d+)$/;
export const REQUIREMENT_REF_REGEX = /^([A-Z][A-Z0-9]*)-(\d+)-(\d+)$/;
export const NOTE_REF_REGEX = /^([A-Z][A-Z0-9]*)-N-(\d+)$/;
export const EPIC_REF_REGEX = /^([A-Z][A-Z0-9]*)-E-(\d+)$/;

export interface SearchNode {
name: string | null;
Expand All @@ -50,4 +55,4 @@ export interface SearchResponse {
totalPages: number;
isLastPage: boolean;
};
}
}