@cyanheads/interpro-mcp-server 0.0.0-stage → 0.1.1

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 (77) hide show
  1. package/AGENTS.md +375 -0
  2. package/CLAUDE.md +375 -0
  3. package/Dockerfile +186 -0
  4. package/LICENSE +201 -0
  5. package/README.md +263 -2
  6. package/changelog/0.1.x/0.1.1.md +20 -0
  7. package/changelog/template.md +151 -0
  8. package/dist/index.d.ts +7 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +34 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/mcp-server/tools/definitions/interpro-find-proteins-by-domain.tool.d.ts +177 -0
  13. package/dist/mcp-server/tools/definitions/interpro-find-proteins-by-domain.tool.d.ts.map +1 -0
  14. package/dist/mcp-server/tools/definitions/interpro-find-proteins-by-domain.tool.js +192 -0
  15. package/dist/mcp-server/tools/definitions/interpro-find-proteins-by-domain.tool.js.map +1 -0
  16. package/dist/mcp-server/tools/definitions/interpro-get-clan.tool.d.ts +160 -0
  17. package/dist/mcp-server/tools/definitions/interpro-get-clan.tool.d.ts.map +1 -0
  18. package/dist/mcp-server/tools/definitions/interpro-get-clan.tool.js +259 -0
  19. package/dist/mcp-server/tools/definitions/interpro-get-clan.tool.js.map +1 -0
  20. package/dist/mcp-server/tools/definitions/interpro-get-entry.tool.d.ts +130 -0
  21. package/dist/mcp-server/tools/definitions/interpro-get-entry.tool.d.ts.map +1 -0
  22. package/dist/mcp-server/tools/definitions/interpro-get-entry.tool.js +100 -0
  23. package/dist/mcp-server/tools/definitions/interpro-get-entry.tool.js.map +1 -0
  24. package/dist/mcp-server/tools/definitions/interpro-get-protein-domains.tool.d.ts +172 -0
  25. package/dist/mcp-server/tools/definitions/interpro-get-protein-domains.tool.d.ts.map +1 -0
  26. package/dist/mcp-server/tools/definitions/interpro-get-protein-domains.tool.js +374 -0
  27. package/dist/mcp-server/tools/definitions/interpro-get-protein-domains.tool.js.map +1 -0
  28. package/dist/mcp-server/tools/definitions/interpro-list-reference.tool.d.ts +89 -0
  29. package/dist/mcp-server/tools/definitions/interpro-list-reference.tool.d.ts.map +1 -0
  30. package/dist/mcp-server/tools/definitions/interpro-list-reference.tool.js +99 -0
  31. package/dist/mcp-server/tools/definitions/interpro-list-reference.tool.js.map +1 -0
  32. package/dist/mcp-server/tools/definitions/interpro-search-entries.tool.d.ts +184 -0
  33. package/dist/mcp-server/tools/definitions/interpro-search-entries.tool.d.ts.map +1 -0
  34. package/dist/mcp-server/tools/definitions/interpro-search-entries.tool.js +155 -0
  35. package/dist/mcp-server/tools/definitions/interpro-search-entries.tool.js.map +1 -0
  36. package/dist/services/interpro/budget.d.ts +26 -0
  37. package/dist/services/interpro/budget.d.ts.map +1 -0
  38. package/dist/services/interpro/budget.js +41 -0
  39. package/dist/services/interpro/budget.js.map +1 -0
  40. package/dist/services/interpro/cursors.d.ts +25 -0
  41. package/dist/services/interpro/cursors.d.ts.map +1 -0
  42. package/dist/services/interpro/cursors.js +99 -0
  43. package/dist/services/interpro/cursors.js.map +1 -0
  44. package/dist/services/interpro/format.d.ts +17 -0
  45. package/dist/services/interpro/format.d.ts.map +1 -0
  46. package/dist/services/interpro/format.js +130 -0
  47. package/dist/services/interpro/format.js.map +1 -0
  48. package/dist/services/interpro/http-adapter.d.ts +11 -0
  49. package/dist/services/interpro/http-adapter.d.ts.map +1 -0
  50. package/dist/services/interpro/http-adapter.js +134 -0
  51. package/dist/services/interpro/http-adapter.js.map +1 -0
  52. package/dist/services/interpro/interpro-service.d.ts +57 -0
  53. package/dist/services/interpro/interpro-service.d.ts.map +1 -0
  54. package/dist/services/interpro/interpro-service.js +284 -0
  55. package/dist/services/interpro/interpro-service.js.map +1 -0
  56. package/dist/services/interpro/reference.d.ts +31 -0
  57. package/dist/services/interpro/reference.d.ts.map +1 -0
  58. package/dist/services/interpro/reference.js +122 -0
  59. package/dist/services/interpro/reference.js.map +1 -0
  60. package/dist/services/interpro/relationships.d.ts +38 -0
  61. package/dist/services/interpro/relationships.d.ts.map +1 -0
  62. package/dist/services/interpro/relationships.js +70 -0
  63. package/dist/services/interpro/relationships.js.map +1 -0
  64. package/dist/services/interpro/routing.d.ts +24 -0
  65. package/dist/services/interpro/routing.d.ts.map +1 -0
  66. package/dist/services/interpro/routing.js +106 -0
  67. package/dist/services/interpro/routing.js.map +1 -0
  68. package/dist/services/interpro/schemas.d.ts +182 -0
  69. package/dist/services/interpro/schemas.d.ts.map +1 -0
  70. package/dist/services/interpro/schemas.js +215 -0
  71. package/dist/services/interpro/schemas.js.map +1 -0
  72. package/dist/services/interpro/upstream-errors.d.ts +43 -0
  73. package/dist/services/interpro/upstream-errors.d.ts.map +1 -0
  74. package/dist/services/interpro/upstream-errors.js +49 -0
  75. package/dist/services/interpro/upstream-errors.js.map +1 -0
  76. package/package.json +103 -4
  77. package/server.json +85 -0
@@ -0,0 +1,172 @@
1
+ /**
2
+ * @fileoverview Protein annotation maps in budget-bounded segments of whole, discontinuous matches.
3
+ * @module mcp-server/tools/definitions/interpro-get-protein-domains.tool
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
+ /** Map signatures to sequence coordinates in budget-bounded segments with explicit coverage. */
8
+ export declare const interproGetProteinDomains: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
9
+ accession: z.ZodString;
10
+ residuePosition: z.ZodOptional<z.ZodNumber>;
11
+ includeExtraFeatures: z.ZodDefault<z.ZodBoolean>;
12
+ cursor: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
13
+ }, z.core.$strip>, z.ZodObject<{
14
+ accession: z.ZodString;
15
+ protein: z.ZodOptional<z.ZodObject<{
16
+ accession: z.ZodString;
17
+ length: z.ZodNumber;
18
+ source_database: z.ZodString;
19
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
+ gene: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
+ source_organism: z.ZodOptional<z.ZodObject<{
22
+ taxId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
23
+ scientificName: z.ZodString;
24
+ fullName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
+ }, z.core.$catchall<z.ZodJSONSchema>>>;
26
+ }, z.core.$catchall<z.ZodJSONSchema>>>;
27
+ matches: z.ZodArray<z.ZodObject<{
28
+ metadata: z.ZodObject<{
29
+ accession: z.ZodString;
30
+ source_database: z.ZodString;
31
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ integrated: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
+ member_databases: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>>>>;
35
+ go_terms: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
36
+ identifier: z.ZodString;
37
+ name: z.ZodString;
38
+ category: z.ZodObject<{
39
+ code: z.ZodString;
40
+ name: z.ZodString;
41
+ }, z.core.$catchall<z.ZodJSONSchema>>;
42
+ }, z.core.$catchall<z.ZodJSONSchema>>>>>;
43
+ }, z.core.$catchall<z.ZodJSONSchema>>;
44
+ proteins: z.ZodArray<z.ZodObject<{
45
+ accession: z.ZodString;
46
+ entry_protein_locations: z.ZodArray<z.ZodObject<{
47
+ fragments: z.ZodArray<z.ZodObject<{
48
+ start: z.ZodNumber;
49
+ end: z.ZodNumber;
50
+ 'dc-status': z.ZodOptional<z.ZodString>;
51
+ }, z.core.$catchall<z.ZodJSONSchema>>>;
52
+ representative: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
53
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
54
+ score: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
55
+ }, z.core.$catchall<z.ZodJSONSchema>>>;
56
+ }, z.core.$catchall<z.ZodJSONSchema>>>;
57
+ }, z.core.$catchall<z.ZodJSONSchema>>>;
58
+ extraFeatures: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
59
+ accession: z.ZodString;
60
+ source_database: z.ZodString;
61
+ locations: z.ZodArray<z.ZodObject<{
62
+ fragments: z.ZodArray<z.ZodObject<{
63
+ start: z.ZodNumber;
64
+ end: z.ZodNumber;
65
+ 'dc-status': z.ZodOptional<z.ZodString>;
66
+ }, z.core.$catchall<z.ZodJSONSchema>>>;
67
+ representative: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
68
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
69
+ score: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
70
+ }, z.core.$catchall<z.ZodJSONSchema>>>;
71
+ }, z.core.$catchall<z.ZodJSONSchema>>>>;
72
+ selection: z.ZodObject<{
73
+ residuePosition: z.ZodOptional<z.ZodNumber>;
74
+ includeExtraFeatures: z.ZodBoolean;
75
+ }, z.core.$strip>;
76
+ coverage: z.ZodObject<{
77
+ totalMatches: z.ZodNumber;
78
+ scannedMatches: z.ZodNumber;
79
+ returnedMatches: z.ZodNumber;
80
+ totalFeatures: z.ZodOptional<z.ZodNumber>;
81
+ returnedFeatures: z.ZodOptional<z.ZodNumber>;
82
+ complete: z.ZodBoolean;
83
+ hasMore: z.ZodBoolean;
84
+ nextCursor: z.ZodOptional<z.ZodString>;
85
+ }, z.core.$strip>;
86
+ url: z.ZodString;
87
+ sourceUrl: z.ZodString;
88
+ }, z.core.$strip>, readonly [{
89
+ readonly reason: "retry_deadline_exceeded";
90
+ readonly code: JsonRpcErrorCode.Timeout;
91
+ readonly when: "The shared fifty-second budget expires across protein metadata, match pages, and extra features.";
92
+ readonly retryable: true;
93
+ readonly recovery: "Retry interpro_get_protein_domains after waiting; omit extra features when they are not needed.";
94
+ readonly thrownBy: "service";
95
+ }, {
96
+ readonly reason: "invalid_cursor";
97
+ readonly code: JsonRpcErrorCode.ValidationError;
98
+ readonly when: "Cursor decoding or scope fails, the records it resumes inside changed or disagree with it, or upstream rejects continuation.";
99
+ readonly retryable: false;
100
+ readonly recovery: "Repeat the same tool without cursor to restart pagination, keeping the intended filters.";
101
+ readonly thrownBy: "service";
102
+ }, {
103
+ readonly reason: "entry_withdrawn";
104
+ readonly code: JsonRpcErrorCode.NotFound;
105
+ readonly when: "InterPro reports a withdrawn record with HTTP 410.";
106
+ readonly retryable: false;
107
+ readonly recovery: "Call interpro_search_entries for a current replacement; consult interpro_list_reference with topic databases for source names.";
108
+ readonly thrownBy: "service";
109
+ }, {
110
+ readonly reason: "upstream_shape_invalid";
111
+ readonly code: JsonRpcErrorCode.ServiceUnavailable;
112
+ readonly when: "Upstream JSON, structure, or continuation is incompatible.";
113
+ readonly retryable: false;
114
+ readonly recovery: "Retry the same tool later; call interpro_list_reference with topic release to check upstream availability.";
115
+ readonly thrownBy: "service";
116
+ }, {
117
+ readonly reason: 'upstream_response_too_large';
118
+ readonly code: JsonRpcErrorCode.ServiceUnavailable;
119
+ readonly when: 'An upstream response exceeds 4 MiB.';
120
+ readonly retryable: false;
121
+ readonly recovery: 'Retry list tools with a smaller limit, or retrieve individual members with interpro_get_entry instead of a large clan.';
122
+ readonly thrownBy: 'service';
123
+ }, {
124
+ readonly reason: 'upstream_rejected';
125
+ readonly code: JsonRpcErrorCode.ServiceUnavailable;
126
+ readonly when: 'InterPro returns an unhandled redirect or client rejection.';
127
+ readonly retryable: false;
128
+ readonly recovery: 'Retry the same tool later; call interpro_list_reference with topic release to check upstream availability.';
129
+ readonly thrownBy: 'service';
130
+ }, {
131
+ readonly reason: 'upstream_unavailable';
132
+ readonly code: JsonRpcErrorCode.ServiceUnavailable;
133
+ readonly when: 'InterPro has a network or server failure; HTTP 501 is not retryable.';
134
+ readonly retryable: true;
135
+ readonly recovery: 'Retry the same tool later; call interpro_list_reference with topic release to check upstream availability.';
136
+ readonly thrownBy: 'service';
137
+ }, {
138
+ readonly reason: 'upstream_timeout';
139
+ readonly code: JsonRpcErrorCode.Timeout;
140
+ readonly when: 'InterPro returns HTTP 408/504 or an attempt exceeds its deadline.';
141
+ readonly retryable: true;
142
+ readonly recovery: 'Retry with a smaller limit where available, then repeat the same tool after waiting.';
143
+ readonly thrownBy: 'service';
144
+ }, {
145
+ readonly reason: 'upstream_rate_limited';
146
+ readonly code: JsonRpcErrorCode.RateLimited;
147
+ readonly when: 'InterPro returns HTTP 429.';
148
+ readonly retryable: true;
149
+ readonly recovery: 'Wait for retryAfter when supplied, then repeat the same tool with fewer concurrent calls.';
150
+ readonly thrownBy: 'service';
151
+ }, {
152
+ readonly reason: "protein_not_found";
153
+ readonly code: JsonRpcErrorCode.NotFound;
154
+ readonly when: "Canonical protein detail returns HTTP 204 or 404.";
155
+ readonly retryable: false;
156
+ readonly recovery: "Use a canonical UniProt accession returned by interpro_find_proteins_by_domain, then retry interpro_get_protein_domains.";
157
+ readonly thrownBy: "service";
158
+ }, {
159
+ readonly reason: "residue_out_of_range";
160
+ readonly code: JsonRpcErrorCode.ValidationError;
161
+ readonly when: "Requested position exceeds the fetched protein length.";
162
+ readonly retryable: false;
163
+ readonly recovery: "Retry interpro_get_protein_domains with residuePosition between one and the returned protein length.";
164
+ }], {
165
+ readonly notice: z.ZodOptional<z.ZodString>;
166
+ readonly totalCount: z.ZodOptional<z.ZodNumber>;
167
+ readonly truncated: z.ZodOptional<z.ZodBoolean>;
168
+ readonly shown: z.ZodOptional<z.ZodNumber>;
169
+ readonly cap: z.ZodOptional<z.ZodNumber>;
170
+ readonly effectiveQuery: z.ZodOptional<z.ZodString>;
171
+ }>;
172
+ //# sourceMappingURL=interpro-get-protein-domains.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interpro-get-protein-domains.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/interpro-get-protein-domains.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAsJjE,gGAAgG;AAChG,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsUpC,CAAC"}
@@ -0,0 +1,374 @@
1
+ /**
2
+ * @fileoverview Protein annotation maps in budget-bounded segments of whole, discontinuous matches.
3
+ * @module mcp-server/tools/definitions/interpro-get-protein-domains.tool
4
+ */
5
+ import { tool, z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
+ import { BUDGET_LABEL, fitWithinBudget, jsonByteLength, RESPONSE_BYTE_BUDGET, } from '../../../services/interpro/budget.js';
8
+ import { compareText, continuation, cursorScope, decodePositionCursor, encodePositionCursor, } from '../../../services/interpro/cursors.js';
9
+ import { formatInterpro, normalizeImages } from '../../../services/interpro/format.js';
10
+ import { getInterproService } from '../../../services/interpro/interpro-service.js';
11
+ import { detailSchema, ExtraFeaturesSchema, isAccession, listSchema, MatchSchema, optionalString, ProteinAccessionSchema, ProteinMetadataSchema, } from '../../../services/interpro/schemas.js';
12
+ import { UPSTREAM_ERRORS } from '../../../services/interpro/upstream-errors.js';
13
+ const OPERATION = 'interpro_get_protein_domains';
14
+ const PAGE_SIZE = 200;
15
+ const MAX_PAGES = 3;
16
+ const SelectionSchema = z.object({
17
+ residuePosition: z
18
+ .number()
19
+ .int()
20
+ .positive()
21
+ .optional()
22
+ .describe('Selected 1-based inclusive residue position.'),
23
+ includeExtraFeatures: z.boolean().describe('Whether extra predicted features were requested.'),
24
+ });
25
+ const CoverageSchema = z.object({
26
+ totalMatches: z
27
+ .number()
28
+ .int()
29
+ .nonnegative()
30
+ .describe('Upstream unfiltered total match count; a segment holding only extra features repeats the count the match list reported.'),
31
+ scannedMatches: z
32
+ .number()
33
+ .int()
34
+ .nonnegative()
35
+ .describe('Match records this segment covered, before residue filtering; across a complete walk the segments sum to totalMatches.'),
36
+ returnedMatches: z
37
+ .number()
38
+ .int()
39
+ .nonnegative()
40
+ .describe('Selected match records in this segment.'),
41
+ totalFeatures: z
42
+ .number()
43
+ .int()
44
+ .nonnegative()
45
+ .optional()
46
+ .describe('Selected extra features for this protein and residue; present with extraFeatures.'),
47
+ returnedFeatures: z
48
+ .number()
49
+ .int()
50
+ .nonnegative()
51
+ .optional()
52
+ .describe('Extra features in this segment; present with extraFeatures.'),
53
+ complete: z
54
+ .boolean()
55
+ .describe('True only when this call starts without a cursor and returns the whole map: every match and every requested extra feature.'),
56
+ hasMore: z
57
+ .boolean()
58
+ .describe('Whether another segment remains, holding more matches or requested extra features.'),
59
+ nextCursor: z
60
+ .string()
61
+ .optional()
62
+ .describe('Opaque cursor resuming at the next whole match or extra feature, for the same protein and selection.'),
63
+ });
64
+ /**
65
+ * Where a continuation resumes: `skip` records into an upstream match page (`page` is that
66
+ * page's upstream cursor, absent for the first page), or `features` selected extra features into
67
+ * the feature list that follows the last match. `after` names the last record an earlier segment
68
+ * covered, so a page or feature list that changed since the cursor was minted is rejected.
69
+ */
70
+ const PositionSchema = z.union([
71
+ z
72
+ .object({
73
+ page: z.string().min(1).optional(),
74
+ skip: z.number().int().nonnegative(),
75
+ after: z.string().min(1).optional(),
76
+ })
77
+ .strict()
78
+ .refine((point) => point.skip > 0 === (point.after !== undefined) &&
79
+ (point.page !== undefined || point.skip > 0)),
80
+ z
81
+ .object({
82
+ features: z.number().int().nonnegative(),
83
+ after: z.string().min(1).optional(),
84
+ totalMatches: z.number().int().nonnegative(),
85
+ })
86
+ .strict()
87
+ .refine((point) => point.features > 0 === (point.after !== undefined)),
88
+ ]);
89
+ function contains(locations, position) {
90
+ return locations.some((location) => location.fragments.some((fragment) => fragment.start <= position && position <= fragment.end));
91
+ }
92
+ function earliest(match) {
93
+ return Math.min(...match.proteins.flatMap((protein) => protein.entry_protein_locations.flatMap((location) => location.fragments.map((fragment) => fragment.start))));
94
+ }
95
+ /** Earliest fragment start, then accession, then canonical JSON: one total order for any page. */
96
+ function byCoordinate(left, right) {
97
+ return (earliest(left) - earliest(right) ||
98
+ compareText(left.metadata.accession, right.metadata.accession) ||
99
+ compareText(cursorScope(left), cursorScope(right)));
100
+ }
101
+ /** Map signatures to sequence coordinates in budget-bounded segments with explicit coverage. */
102
+ export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
103
+ title: 'Map protein domains',
104
+ description: 'Retrieve InterPro and member-signature matches on a canonical UniProt protein, preserving every location and discontinuous fragment. Optionally retain matches covering a residue and include extra predicted features. Large maps arrive in segments of whole matches that fit the response budget: the first segment carries the protein metadata, requested extra features follow the last match, and coverage.nextCursor continues until hasMore is false.',
105
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
106
+ auth: ['tool:interpro_get_protein_domains:read'],
107
+ input: z.object({
108
+ accession: ProteinAccessionSchema,
109
+ residuePosition: z
110
+ .number()
111
+ .int()
112
+ .positive()
113
+ .optional()
114
+ .describe('Residue position, 1-based and inclusive; must not exceed protein length.'),
115
+ includeExtraFeatures: z
116
+ .boolean()
117
+ .default(false)
118
+ .describe('Include complete extra predicted features, returned after the last match; defaults to false.'),
119
+ cursor: optionalString(z.string().trim().max(4096)).describe('Opaque coverage.nextCursor with unchanged accession, residuePosition, and includeExtraFeatures.'),
120
+ }),
121
+ output: z.object({
122
+ accession: z.string().describe('Canonical UniProt accession.'),
123
+ protein: ProteinMetadataSchema.optional().describe('Complete upstream protein metadata on the first segment, the call without cursor; continuation segments omit it.'),
124
+ matches: z
125
+ .array(MatchSchema.describe('Complete entry match record.'))
126
+ .describe('Whole selected match records in this segment, sorted by earliest coordinate then accession; a match is never split across segments.'),
127
+ extraFeatures: ExtraFeaturesSchema.optional().describe('Whole selected extra features in this segment, in feature-key order; {} when none are selected. Omitted when not requested or when this segment ends before the features that follow the last match.'),
128
+ selection: SelectionSchema.describe('Applied residue and extra-feature selection.'),
129
+ coverage: CoverageSchema.describe('Where this segment sits in the protein map: every match, then requested extra features.'),
130
+ url: z.string().describe('Canonical protein website URL.'),
131
+ sourceUrl: z.string().describe('Official protein API source URL.'),
132
+ }),
133
+ enrichment: {
134
+ notice: z.string().optional().describe('Interpretation, continuation, or recovery guidance.'),
135
+ totalCount: z.number().optional().describe('Upstream total matching records.'),
136
+ truncated: z.boolean().optional().describe('More segments remain.'),
137
+ shown: z.number().int().optional().describe('Selected match records in this segment.'),
138
+ cap: z
139
+ .number()
140
+ .int()
141
+ .optional()
142
+ .describe('Most match records one call reads; a segment can stop sooner at the response byte budget.'),
143
+ effectiveQuery: z.string().optional().describe('Applied selection as JSON.'),
144
+ },
145
+ errors: [
146
+ {
147
+ reason: 'retry_deadline_exceeded',
148
+ code: JsonRpcErrorCode.Timeout,
149
+ when: 'The shared fifty-second budget expires across protein metadata, match pages, and extra features.',
150
+ retryable: true,
151
+ recovery: 'Retry interpro_get_protein_domains after waiting; omit extra features when they are not needed.',
152
+ thrownBy: 'service',
153
+ },
154
+ {
155
+ reason: 'invalid_cursor',
156
+ code: JsonRpcErrorCode.ValidationError,
157
+ when: 'Cursor decoding or scope fails, the records it resumes inside changed or disagree with it, or upstream rejects continuation.',
158
+ retryable: false,
159
+ recovery: 'Repeat the same tool without cursor to restart pagination, keeping the intended filters.',
160
+ thrownBy: 'service',
161
+ },
162
+ {
163
+ reason: 'entry_withdrawn',
164
+ code: JsonRpcErrorCode.NotFound,
165
+ when: 'InterPro reports a withdrawn record with HTTP 410.',
166
+ retryable: false,
167
+ recovery: 'Call interpro_search_entries for a current replacement; consult interpro_list_reference with topic databases for source names.',
168
+ thrownBy: 'service',
169
+ },
170
+ {
171
+ reason: 'upstream_shape_invalid',
172
+ code: JsonRpcErrorCode.ServiceUnavailable,
173
+ when: 'Upstream JSON, structure, or continuation is incompatible.',
174
+ retryable: false,
175
+ recovery: 'Retry the same tool later; call interpro_list_reference with topic release to check upstream availability.',
176
+ thrownBy: 'service',
177
+ },
178
+ ...UPSTREAM_ERRORS,
179
+ {
180
+ reason: 'protein_not_found',
181
+ code: JsonRpcErrorCode.NotFound,
182
+ when: 'Canonical protein detail returns HTTP 204 or 404.',
183
+ retryable: false,
184
+ recovery: 'Use a canonical UniProt accession returned by interpro_find_proteins_by_domain, then retry interpro_get_protein_domains.',
185
+ thrownBy: 'service',
186
+ },
187
+ {
188
+ reason: 'residue_out_of_range',
189
+ code: JsonRpcErrorCode.ValidationError,
190
+ when: 'Requested position exceeds the fetched protein length.',
191
+ retryable: false,
192
+ recovery: 'Retry interpro_get_protein_domains with residuePosition between one and the returned protein length.',
193
+ },
194
+ ],
195
+ async handler(input, ctx) {
196
+ const accession = input.accession.toUpperCase();
197
+ const residue = input.residuePosition;
198
+ const selection = {
199
+ ...(residue !== undefined ? { residuePosition: residue } : {}),
200
+ includeExtraFeatures: input.includeExtraFeatures,
201
+ };
202
+ const scope = { accession, ...selection };
203
+ const start = decodePositionCursor(input.cursor, OPERATION, scope, PositionSchema);
204
+ const stale = () => ctx.fail('invalid_cursor', 'Cursor no longer matches the InterPro records it resumes inside.');
205
+ if (start && 'features' in start && !input.includeExtraFeatures)
206
+ throw stale();
207
+ const resumed = start !== undefined;
208
+ const covers = (locations) => residue === undefined || contains(locations, residue);
209
+ const service = getInterproService();
210
+ const call = service.begin(ctx);
211
+ const detail = await service.request(call, ['protein', 'uniprot', accession], {}, detailSchema(ProteinMetadataSchema), { missing: { reason: 'protein_not_found', accession, sourceDatabase: 'uniprot' } });
212
+ if (!detail.data)
213
+ throw ctx.fail('upstream_shape_invalid', 'Protein metadata response is missing.');
214
+ const protein = normalizeImages(detail.data.metadata);
215
+ if (residue !== undefined && residue > protein.length)
216
+ throw ctx.fail('residue_out_of_range', `Residue ${residue} exceeds the ${protein.length}-residue length of ${accession}.`, { accession, proteinLength: protein.length, residuePosition: residue });
217
+ /** Whole candidate items in walk order: every match, then every selected extra feature. */
218
+ const items = [];
219
+ let scanned = 0;
220
+ let totalMatches = start && 'features' in start ? start.totalMatches : 0;
221
+ let totalFeatures;
222
+ /** Where the walk resumes after the last gathered item; undefined once the walk ends. */
223
+ let end;
224
+ const segment = (count) => {
225
+ const stop = items[count];
226
+ const resume = stop ? stop.at : end;
227
+ const matches = [];
228
+ const features = [];
229
+ for (const item of items.slice(0, count))
230
+ if (item.kind === 'match')
231
+ matches.push(item.match);
232
+ else
233
+ features.push([item.key, item.feature]);
234
+ const featureTotal = totalFeatures;
235
+ const reachedFeatures = featureTotal !== undefined && (features.length > 0 || resume === undefined);
236
+ return {
237
+ accession,
238
+ ...(resumed ? {} : { protein }),
239
+ matches: matches.toSorted(byCoordinate),
240
+ ...(reachedFeatures ? { extraFeatures: Object.fromEntries(features) } : {}),
241
+ selection,
242
+ coverage: {
243
+ totalMatches,
244
+ scannedMatches: stop ? stop.scannedBefore : scanned,
245
+ returnedMatches: matches.length,
246
+ ...(reachedFeatures
247
+ ? { totalFeatures: featureTotal, returnedFeatures: features.length }
248
+ : {}),
249
+ complete: !resumed && resume === undefined,
250
+ hasMore: resume !== undefined,
251
+ ...(resume ? { nextCursor: encodePositionCursor(OPERATION, scope, resume) } : {}),
252
+ },
253
+ url: `https://www.ebi.ac.uk/interpro/protein/UniProt/${accession}/`,
254
+ sourceUrl: detail.sourceUrl,
255
+ };
256
+ };
257
+ const overflows = () => items.length > 0 && jsonByteLength(segment(items.length)) > RESPONSE_BYTE_BUDGET;
258
+ if (!start || 'skip' in start) {
259
+ let page = start?.page;
260
+ let skip = start?.skip ?? 0;
261
+ const seen = new Set(page ? [page] : []);
262
+ for (let read = 1;; read++) {
263
+ const response = await service.request(call, ['entry', 'all', 'protein', 'uniprot', accession], { page_size: PAGE_SIZE, cursor: page }, listSchema(MatchSchema), { continuation: page !== undefined });
264
+ if (read === 1)
265
+ totalMatches = response.data?.count ?? 0;
266
+ const records = normalizeImages(response.data?.results ?? []).toSorted(byCoordinate);
267
+ if (skip > 0 &&
268
+ (skip >= records.length || records[skip - 1]?.metadata.accession !== start?.after))
269
+ throw stale();
270
+ for (let index = skip; index < records.length; index++) {
271
+ const match = records[index];
272
+ if (match.proteins.some((record) => covers(record.entry_protein_locations)))
273
+ items.push({
274
+ kind: 'match',
275
+ match,
276
+ scannedBefore: scanned,
277
+ at: {
278
+ ...(page ? { page } : {}),
279
+ skip: index,
280
+ ...(index ? { after: records[index - 1].metadata.accession } : {}),
281
+ },
282
+ });
283
+ scanned += 1;
284
+ }
285
+ const next = continuation(response.data?.next ?? null, seen);
286
+ end = next ? { page: next, skip: 0 } : undefined;
287
+ if (!next)
288
+ break;
289
+ seen.add(next);
290
+ page = next;
291
+ skip = 0;
292
+ if (read === MAX_PAGES || overflows())
293
+ break;
294
+ }
295
+ }
296
+ if (input.includeExtraFeatures && end === undefined) {
297
+ // Read extras only when the matches fit beside the cursor that would resume at them.
298
+ end = { features: 0, totalMatches };
299
+ if (!overflows()) {
300
+ end = undefined;
301
+ const extras = await service.request(call, ['protein', 'uniprot', accession], { extra_features: '' }, ExtraFeaturesSchema);
302
+ if (!extras.data)
303
+ throw ctx.fail('upstream_shape_invalid', 'Extra feature response is missing.');
304
+ const selected = Object.entries(normalizeImages(extras.data))
305
+ .filter(([, feature]) => covers(feature.locations))
306
+ .toSorted(([a], [b]) => compareText(a, b));
307
+ const resumeAt = start && 'features' in start ? start : undefined;
308
+ const skip = resumeAt?.features ?? 0;
309
+ if (skip > 0 && (skip >= selected.length || selected[skip - 1]?.[0] !== resumeAt?.after))
310
+ throw stale();
311
+ totalFeatures = selected.length;
312
+ for (let index = skip; index < selected.length; index++) {
313
+ const [key, feature] = selected[index];
314
+ items.push({
315
+ kind: 'feature',
316
+ key,
317
+ feature,
318
+ scannedBefore: scanned,
319
+ at: {
320
+ features: index,
321
+ ...(index ? { after: selected[index - 1][0] } : {}),
322
+ totalMatches,
323
+ },
324
+ });
325
+ }
326
+ }
327
+ }
328
+ const { count, output, oversized } = fitWithinBudget(items.length, segment);
329
+ const { coverage } = output;
330
+ const stop = items[count];
331
+ const notices = [];
332
+ if (oversized) {
333
+ const only = items[0];
334
+ const [named, unnamed, id] = only.kind === 'feature'
335
+ ? ['Extra feature', 'This extra feature', only.key]
336
+ : ['Match', 'This match', only.match.metadata.accession];
337
+ notices.push(`${isAccession(id) ? `${named} ${id}` : unnamed} cannot be split, so this segment holds it alone and exceeds the ${BUDGET_LABEL}.`);
338
+ }
339
+ if (coverage.nextCursor) {
340
+ const reason = stop
341
+ ? ` and stopped at the ${BUDGET_LABEL} before the next whole ${stop.kind === 'match' ? 'match' : 'extra feature'}`
342
+ : oversized
343
+ ? ''
344
+ : ` and reached the ${MAX_PAGES}-page read limit after ${coverage.scannedMatches} match records`;
345
+ const nextCall = {
346
+ accession,
347
+ ...(residue !== undefined ? { residuePosition: residue } : {}),
348
+ ...(input.includeExtraFeatures ? { includeExtraFeatures: true } : {}),
349
+ cursor: coverage.nextCursor,
350
+ };
351
+ notices.push(`This segment covers part of the protein map${reason}. Continue with interpro_get_protein_domains ${JSON.stringify(nextCall)} before concluding that a residue has no annotation.`);
352
+ }
353
+ else if (resumed)
354
+ notices.push('This is the final resumed segment. Only the combined segments cover the traversal; upstream pagination is not a snapshot.' +
355
+ (coverage.returnedMatches || 'features' in start
356
+ ? ''
357
+ : ' No match was selected in this segment.'));
358
+ else if (!coverage.returnedMatches)
359
+ notices.push(residue === undefined
360
+ ? 'The protein has no returned signature matches. Annotation is not a clinical interpretation.'
361
+ : 'No match contains this position. Annotation is not a clinical interpretation.');
362
+ if (resumed)
363
+ notices.push('Continuation segments omit the protein metadata the first segment returned.');
364
+ ctx.enrich.total(totalMatches);
365
+ ctx.enrich.echo(JSON.stringify(scope));
366
+ if (coverage.nextCursor)
367
+ ctx.enrich.truncated({ shown: coverage.returnedMatches, cap: MAX_PAGES * PAGE_SIZE });
368
+ if (notices.length)
369
+ ctx.enrich.notice(notices.join(' '));
370
+ return output;
371
+ },
372
+ format: formatInterpro,
373
+ });
374
+ //# sourceMappingURL=interpro-get-protein-domains.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interpro-get-protein-domains.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/interpro-get-protein-domains.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,cAAc,EACd,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,WAAW,EAEX,UAAU,EACV,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAEzE,MAAM,SAAS,GAAG,8BAA8B,CAAC;AACjD,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,eAAe,EAAE,CAAC;SACf,MAAM,EAAE;SACR,GAAG,EAAE;SACL,QAAQ,EAAE;SACV,QAAQ,EAAE;SACV,QAAQ,CAAC,8CAA8C,CAAC;IAC3D,oBAAoB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,kDAAkD,CAAC;CAC/F,CAAC,CAAC;AACH,MAAM,cAAc,GAAG,CAAC,CA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