@firfi/huly-mcp 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 (36) hide show
  1. package/dist/index.cjs +144012 -0
  2. package/dist/index.js +116694 -0
  3. package/dist/src/config/config.d.ts +94 -0
  4. package/dist/src/config/config.d.ts.map +1 -0
  5. package/dist/src/config/config.js +247 -0
  6. package/dist/src/config/config.js.map +1 -0
  7. package/dist/src/domain/schemas.d.ts +256 -0
  8. package/dist/src/domain/schemas.d.ts.map +1 -0
  9. package/dist/src/domain/schemas.js +275 -0
  10. package/dist/src/domain/schemas.js.map +1 -0
  11. package/dist/src/huly/client.d.ts +63 -0
  12. package/dist/src/huly/client.d.ts.map +1 -0
  13. package/dist/src/huly/client.js +149 -0
  14. package/dist/src/huly/client.js.map +1 -0
  15. package/dist/src/huly/errors.d.ts +133 -0
  16. package/dist/src/huly/errors.d.ts.map +1 -0
  17. package/dist/src/huly/errors.js +108 -0
  18. package/dist/src/huly/errors.js.map +1 -0
  19. package/dist/src/huly/operations/issues.d.ts +122 -0
  20. package/dist/src/huly/operations/issues.d.ts.map +1 -0
  21. package/dist/src/huly/operations/issues.js +627 -0
  22. package/dist/src/huly/operations/issues.js.map +1 -0
  23. package/dist/src/index.d.ts +43 -0
  24. package/dist/src/index.d.ts.map +1 -0
  25. package/dist/src/index.js +154 -0
  26. package/dist/src/index.js.map +1 -0
  27. package/dist/src/mcp/error-mapping.d.ts +67 -0
  28. package/dist/src/mcp/error-mapping.d.ts.map +1 -0
  29. package/dist/src/mcp/error-mapping.js +195 -0
  30. package/dist/src/mcp/error-mapping.js.map +1 -0
  31. package/dist/src/mcp/server.d.ts +86 -0
  32. package/dist/src/mcp/server.d.ts.map +1 -0
  33. package/dist/src/mcp/server.js +216 -0
  34. package/dist/src/mcp/server.js.map +1 -0
  35. package/dist/tsconfig.tsbuildinfo +1 -0
  36. package/package.json +61 -0
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Error hierarchy for Huly MCP server.
3
+ *
4
+ * Tagged errors for pattern matching in Effect code.
5
+ * Maps to MCP error codes:
6
+ * - -32602 (Invalid params): IssueNotFoundError, ProjectNotFoundError, InvalidStatusError
7
+ * - -32603 (Internal error): HulyConnectionError, HulyAuthError, HulyError
8
+ *
9
+ * @module
10
+ */
11
+ import { Schema } from "effect";
12
+ /**
13
+ * MCP standard error codes.
14
+ */
15
+ export const McpErrorCode = {
16
+ InvalidParams: -32602,
17
+ InternalError: -32603,
18
+ };
19
+ /**
20
+ * Base Huly error - generic operational error.
21
+ * Maps to MCP -32603 (Internal error).
22
+ */
23
+ export class HulyError extends Schema.TaggedError()("HulyError", {
24
+ message: Schema.String,
25
+ cause: Schema.optional(Schema.Defect),
26
+ }) {
27
+ mcpErrorCode = McpErrorCode.InternalError;
28
+ }
29
+ /**
30
+ * Connection error - network/transport failures.
31
+ * Maps to MCP -32603 (Internal error).
32
+ */
33
+ export class HulyConnectionError extends Schema.TaggedError()("HulyConnectionError", {
34
+ message: Schema.String,
35
+ cause: Schema.optional(Schema.Defect),
36
+ }) {
37
+ mcpErrorCode = McpErrorCode.InternalError;
38
+ }
39
+ /**
40
+ * Authentication error - invalid credentials or expired session.
41
+ * Maps to MCP -32603 (Internal error).
42
+ */
43
+ export class HulyAuthError extends Schema.TaggedError()("HulyAuthError", {
44
+ message: Schema.String,
45
+ }) {
46
+ mcpErrorCode = McpErrorCode.InternalError;
47
+ }
48
+ /**
49
+ * Issue not found in the specified project.
50
+ * Maps to MCP -32602 (Invalid params).
51
+ */
52
+ export class IssueNotFoundError extends Schema.TaggedError()("IssueNotFoundError", {
53
+ identifier: Schema.String,
54
+ project: Schema.String,
55
+ }) {
56
+ mcpErrorCode = McpErrorCode.InvalidParams;
57
+ get message() {
58
+ return `Issue '${this.identifier}' not found in project '${this.project}'`;
59
+ }
60
+ }
61
+ /**
62
+ * Project not found in the workspace.
63
+ * Maps to MCP -32602 (Invalid params).
64
+ */
65
+ export class ProjectNotFoundError extends Schema.TaggedError()("ProjectNotFoundError", {
66
+ identifier: Schema.String,
67
+ }) {
68
+ mcpErrorCode = McpErrorCode.InvalidParams;
69
+ get message() {
70
+ return `Project '${this.identifier}' not found`;
71
+ }
72
+ }
73
+ /**
74
+ * Invalid status for the given project.
75
+ * Maps to MCP -32602 (Invalid params).
76
+ */
77
+ export class InvalidStatusError extends Schema.TaggedError()("InvalidStatusError", {
78
+ status: Schema.String,
79
+ project: Schema.String,
80
+ }) {
81
+ mcpErrorCode = McpErrorCode.InvalidParams;
82
+ get message() {
83
+ return `Invalid status '${this.status}' for project '${this.project}'`;
84
+ }
85
+ }
86
+ /**
87
+ * Person (assignee) not found.
88
+ * Maps to MCP -32602 (Invalid params).
89
+ */
90
+ export class PersonNotFoundError extends Schema.TaggedError()("PersonNotFoundError", {
91
+ identifier: Schema.String,
92
+ }) {
93
+ mcpErrorCode = McpErrorCode.InvalidParams;
94
+ get message() {
95
+ return `Person '${this.identifier}' not found`;
96
+ }
97
+ }
98
+ /**
99
+ * Schema for all Huly domain errors (for serialization).
100
+ */
101
+ export const HulyDomainError = Schema.Union(HulyError, HulyConnectionError, HulyAuthError, IssueNotFoundError, ProjectNotFoundError, InvalidStatusError, PersonNotFoundError);
102
+ /**
103
+ * Get MCP error code from a Huly domain error.
104
+ */
105
+ export const getMcpErrorCode = (error) => {
106
+ return error.mcpErrorCode;
107
+ };
108
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/huly/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,aAAa,EAAE,CAAC,KAAK;IACrB,aAAa,EAAE,CAAC,KAAK;CACb,CAAA;AAIV;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,WAAW,E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AAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC,WAAW,EAAsB,CAC9E,oBAAoB,EACpB;IACE,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CACF;IACU,YAAY,GAAiB,YAAY,CAAC,aAAa,CAAA;IAEhE,IAAa,OAAO;QAClB,OAAO,mBAAmB,IAAI,CAAC,MAAM,kBAAkB,IAAI,CAAC,OAAO,GAAG,CAAA;IACxE,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,MAAM,CAAC,WAAW,EAAuB,CAChF,qBAAqB,EACrB;IACE,UAAU,EAAE,MAAM,CAAC,MAAM;CAC1B,CACF;IACU,YAAY,GAAiB,YAAY,CAAC,aAAa,CAAA;IAEhE,IAAa,OAAO;QAClB,OAAO,WAAW,IAAI,CAAC,UAAU,aAAa,CAAA;IAChD,CAAC;CACF;AAcD;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAUxB,MAAM,CAAC,KAAK,CACd,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,CACpB,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAsB,EAAgB,EAAE;IACtE,OAAO,KAAK,CAAC,YAAY,CAAA;AAC3B,CAAC,CAAA"}
@@ -0,0 +1,122 @@
1
+ import { Effect } from "effect";
2
+ import { HulyClient, type HulyClientError } from "../client.js";
3
+ import { ProjectNotFoundError, InvalidStatusError, IssueNotFoundError, PersonNotFoundError } from "../errors.js";
4
+ import type { IssueSummary, ListIssuesParams, GetIssueParams, CreateIssueParams, UpdateIssueParams, AddLabelParams, Issue } from "../../domain/schemas.js";
5
+ /**
6
+ * Errors that listIssues can produce.
7
+ */
8
+ export type ListIssuesError = HulyClientError | ProjectNotFoundError | InvalidStatusError;
9
+ /**
10
+ * Errors that getIssue can produce.
11
+ */
12
+ export type GetIssueError = HulyClientError | ProjectNotFoundError | IssueNotFoundError;
13
+ /**
14
+ * Errors that createIssue can produce.
15
+ */
16
+ export type CreateIssueError = HulyClientError | ProjectNotFoundError | InvalidStatusError | PersonNotFoundError;
17
+ /**
18
+ * Errors that updateIssue can produce.
19
+ */
20
+ export type UpdateIssueError = HulyClientError | ProjectNotFoundError | IssueNotFoundError | InvalidStatusError | PersonNotFoundError;
21
+ /**
22
+ * Errors that addLabel can produce.
23
+ */
24
+ export type AddLabelError = HulyClientError | ProjectNotFoundError | IssueNotFoundError;
25
+ /**
26
+ * List issues with filters.
27
+ *
28
+ * Filters:
29
+ * - project (required): Project identifier
30
+ * - status: "open" | "done" | "canceled" | specific status name
31
+ * - assignee: Email or person name
32
+ * - limit: Max results (default 50, max 200)
33
+ *
34
+ * Results sorted by modifiedOn descending.
35
+ */
36
+ export declare const listIssues: (params: ListIssuesParams) => Effect.Effect<IssueSummary[], ListIssuesError, HulyClient>;
37
+ /**
38
+ * Get a single issue with full details.
39
+ *
40
+ * Looks up issue by identifier (e.g., "HULY-123" or just 123).
41
+ * Returns full issue including:
42
+ * - Description rendered as markdown
43
+ * - Assignee name (not just ID)
44
+ * - Status name
45
+ * - All metadata
46
+ *
47
+ * @param params - Get issue parameters
48
+ * @returns Full issue object
49
+ * @throws ProjectNotFoundError if project doesn't exist
50
+ * @throws IssueNotFoundError if issue doesn't exist in project
51
+ */
52
+ export declare const getIssue: (params: GetIssueParams) => Effect.Effect<Issue, GetIssueError, HulyClient>;
53
+ /**
54
+ * Result of createIssue operation.
55
+ */
56
+ export interface CreateIssueResult {
57
+ identifier: string;
58
+ }
59
+ /**
60
+ * Create a new issue in a project.
61
+ *
62
+ * Creates issue with:
63
+ * - Title (required)
64
+ * - Description (optional, markdown supported)
65
+ * - Priority (optional, defaults to no-priority)
66
+ * - Status (optional, uses project default)
67
+ * - Assignee (optional, by email or name)
68
+ *
69
+ * @param params - Create issue parameters
70
+ * @returns Created issue identifier (e.g., "HULY-123")
71
+ * @throws ProjectNotFoundError if project doesn't exist
72
+ * @throws InvalidStatusError if specified status is invalid
73
+ * @throws PersonNotFoundError if assignee not found
74
+ */
75
+ export declare const createIssue: (params: CreateIssueParams) => Effect.Effect<CreateIssueResult, CreateIssueError, HulyClient>;
76
+ /**
77
+ * Result of updateIssue operation.
78
+ */
79
+ export interface UpdateIssueResult {
80
+ identifier: string;
81
+ updated: boolean;
82
+ }
83
+ /**
84
+ * Update an existing issue in a project.
85
+ *
86
+ * Updates only provided fields:
87
+ * - title: New title
88
+ * - description: New markdown description (uploaded via uploadMarkup)
89
+ * - status: New status (resolved by name)
90
+ * - priority: New priority
91
+ * - assignee: New assignee email/name, or null to unassign
92
+ *
93
+ * @param params - Update issue parameters
94
+ * @returns Updated issue identifier and success flag
95
+ * @throws ProjectNotFoundError if project doesn't exist
96
+ * @throws IssueNotFoundError if issue doesn't exist
97
+ * @throws InvalidStatusError if specified status is invalid
98
+ * @throws PersonNotFoundError if assignee not found
99
+ */
100
+ export declare const updateIssue: (params: UpdateIssueParams) => Effect.Effect<UpdateIssueResult, UpdateIssueError, HulyClient>;
101
+ /**
102
+ * Result of addLabel operation.
103
+ */
104
+ export interface AddLabelResult {
105
+ identifier: string;
106
+ labelAdded: boolean;
107
+ }
108
+ /**
109
+ * Add a label/tag to an issue.
110
+ *
111
+ * Creates the tag in the project if it doesn't exist,
112
+ * then attaches it to the issue via TagReference.
113
+ *
114
+ * Idempotent: adding the same label twice is a no-op.
115
+ *
116
+ * @param params - Add label parameters
117
+ * @returns Issue identifier and whether label was added
118
+ * @throws ProjectNotFoundError if project doesn't exist
119
+ * @throws IssueNotFoundError if issue doesn't exist
120
+ */
121
+ export declare const addLabel: (params: AddLabelParams) => Effect.Effect<AddLabelResult, AddLabelError, HulyClient>;
122
+ //# sourceMappingURL=issues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../../../../src/huly/operations/issues.ts"],"names":[],"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