@cyanheads/interpro-mcp-server 0.1.2 → 0.1.3

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 (31) hide show
  1. package/AGENTS.md +4 -4
  2. package/CLAUDE.md +4 -4
  3. package/README.md +33 -7
  4. package/changelog/0.1.x/0.1.3.md +24 -0
  5. package/dist/index.js +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/mcp-server/tools/definitions/interpro-find-proteins-by-domain.tool.d.ts +44 -2
  8. package/dist/mcp-server/tools/definitions/interpro-find-proteins-by-domain.tool.d.ts.map +1 -1
  9. package/dist/mcp-server/tools/definitions/interpro-find-proteins-by-domain.tool.js +56 -4
  10. package/dist/mcp-server/tools/definitions/interpro-find-proteins-by-domain.tool.js.map +1 -1
  11. package/dist/mcp-server/tools/definitions/interpro-get-entry.tool.d.ts +59 -0
  12. package/dist/mcp-server/tools/definitions/interpro-get-entry.tool.d.ts.map +1 -1
  13. package/dist/mcp-server/tools/definitions/interpro-get-entry.tool.js +139 -5
  14. package/dist/mcp-server/tools/definitions/interpro-get-entry.tool.js.map +1 -1
  15. package/dist/mcp-server/tools/definitions/interpro-get-protein-domains.tool.d.ts +20 -2
  16. package/dist/mcp-server/tools/definitions/interpro-get-protein-domains.tool.d.ts.map +1 -1
  17. package/dist/mcp-server/tools/definitions/interpro-get-protein-domains.tool.js +98 -22
  18. package/dist/mcp-server/tools/definitions/interpro-get-protein-domains.tool.js.map +1 -1
  19. package/dist/mcp-server/tools/definitions/interpro-search-entries.tool.d.ts +6 -0
  20. package/dist/mcp-server/tools/definitions/interpro-search-entries.tool.d.ts.map +1 -1
  21. package/dist/mcp-server/tools/definitions/interpro-search-entries.tool.js +11 -2
  22. package/dist/mcp-server/tools/definitions/interpro-search-entries.tool.js.map +1 -1
  23. package/dist/services/interpro/format.d.ts.map +1 -1
  24. package/dist/services/interpro/format.js +8 -17
  25. package/dist/services/interpro/format.js.map +1 -1
  26. package/dist/services/interpro/schemas.d.ts +15 -0
  27. package/dist/services/interpro/schemas.d.ts.map +1 -1
  28. package/dist/services/interpro/schemas.js +8 -0
  29. package/dist/services/interpro/schemas.js.map +1 -1
  30. package/package.json +3 -3
  31. package/server.json +3 -3
@@ -10,10 +10,45 @@ import { getInterproService } from '../../../services/interpro/interpro-service.
10
10
  import { resolveEntry } from '../../../services/interpro/routing.js';
11
11
  import { AccessionSchema, detailSchema, EntryDetailMetadataSchema, EntryMetadataSchema, optionalString, SourceDatabaseSchema, } from '../../../services/interpro/schemas.js';
12
12
  import { UPSTREAM_ERRORS } from '../../../services/interpro/upstream-errors.js';
13
+ const SECTIONS = [
14
+ 'description',
15
+ 'hierarchy',
16
+ 'member_databases',
17
+ 'go_terms',
18
+ 'literature',
19
+ 'cross_references',
20
+ 'wikipedia',
21
+ 'counters',
22
+ 'overlaps_with',
23
+ ];
24
+ const SectionSchema = z.enum(SECTIONS);
25
+ const OverlapsPageSchema = z.discriminatedUnion('available', [
26
+ z
27
+ .object({
28
+ available: z.literal(true).describe('Overlap array was supplied.'),
29
+ total: z.number().int().nonnegative().describe('Complete upstream overlap count.'),
30
+ offset: z.number().int().nonnegative().describe('Requested record offset.'),
31
+ returned: z.number().int().nonnegative().describe('Complete records returned.'),
32
+ hasMore: z.boolean().describe('More overlap records remain.'),
33
+ nextOffset: z
34
+ .number()
35
+ .int()
36
+ .nonnegative()
37
+ .optional()
38
+ .describe('Next offset when more records remain.'),
39
+ })
40
+ .describe('Page of complete upstream overlap records.'),
41
+ z
42
+ .object({
43
+ available: z.literal(false).describe('Overlap array was not supplied.'),
44
+ offset: z.number().int().nonnegative().describe('Requested record offset.'),
45
+ })
46
+ .describe('Overlap paging unavailable for a missing or null source section.'),
47
+ ]);
13
48
  /** Retrieve one complete entry with deterministic accession routing. */
14
49
  export const interproGetEntry = tool('interpro_get_entry', {
15
50
  title: 'InterPro entry metadata',
16
- description: 'Retrieve one InterPro or member-database entry, including description, hierarchy, member signatures, GO terms, literature, cross-references, clan membership, and coverage counters.',
51
+ description: 'Retrieve one InterPro or member-database entry with full metadata by default. Select optional sections while retaining core and unknown metadata, or supply overlapLimit to page whole overlap records in upstream order; offsets are not a snapshot across calls.',
17
52
  annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
18
53
  auth: ['tool:interpro_get_entry:read'],
19
54
  input: z.object({
@@ -23,21 +58,68 @@ export const interproGetEntry = tool('interpro_get_entry', {
23
58
  .boolean()
24
59
  .default(false)
25
60
  .describe('Include each Wikipedia thumbnail image, base64 data often hundreds of KB; defaults to false.'),
61
+ sections: z
62
+ .array(SectionSchema.describe('Optional metadata section to retain.'))
63
+ .optional()
64
+ .describe('Retain these named sections and all core or unknown metadata; omitted means full detail, and an empty array retains core metadata only.'),
65
+ overlapLimit: z
66
+ .number()
67
+ .int()
68
+ .positive()
69
+ .max(Number.MAX_SAFE_INTEGER)
70
+ .optional()
71
+ .describe('Positive safe integer number of whole overlap records; supplying it enables overlap paging.'),
72
+ overlapOffset: z
73
+ .number()
74
+ .int()
75
+ .nonnegative()
76
+ .max(Number.MAX_SAFE_INTEGER)
77
+ .optional()
78
+ .describe('Nonnegative safe integer overlap offset; requires overlapLimit, defaults to zero.'),
26
79
  }),
27
80
  output: z.object({
28
81
  accession: z.string().describe('Canonical requested accession.'),
29
82
  sourceDatabase: SourceDatabaseSchema,
30
- entry: EntryDetailMetadataSchema.describe('Complete upstream metadata with readable descriptionText, preserving raw description shapes and sparse annotations; Wikipedia thumbnails are omitted unless includeThumbnail is true.'),
83
+ entry: EntryDetailMetadataSchema.describe('Upstream metadata after explicit section selection and overlap paging, with readable descriptionText when description is retained; raw description shapes and sparse annotations survive. Wikipedia thumbnails are omitted unless includeThumbnail is true.'),
31
84
  url: z.string().describe('Canonical InterPro website URL.'),
32
85
  sourceUrl: z.string().describe('Official API source URL.'),
86
+ sections: z
87
+ .array(SectionSchema.describe('Retained optional section.'))
88
+ .optional()
89
+ .describe('Canonical selected sections, when explicitly selected.'),
90
+ omittedSections: z
91
+ .array(SectionSchema.describe('Omitted source section.'))
92
+ .optional()
93
+ .describe('Named sections actually removed from upstream metadata.'),
94
+ overlapsPage: OverlapsPageSchema.optional().describe('Explicit overlap paging state; unavailable arrays have no fabricated total.'),
33
95
  }),
34
96
  enrichment: {
97
+ totalCount: z
98
+ .number()
99
+ .int()
100
+ .nonnegative()
101
+ .optional()
102
+ .describe('Total upstream overlap records when explicit paging has an available array.'),
35
103
  notice: z
36
104
  .string()
37
105
  .optional()
38
- .describe('Omitted Wikipedia thumbnail size and how to include it.'),
106
+ .describe('Section selection, overlap page continuation or availability, and omitted Wikipedia thumbnail guidance.'),
39
107
  },
40
108
  errors: [
109
+ {
110
+ reason: 'overlap_limit_required',
111
+ code: JsonRpcErrorCode.ValidationError,
112
+ when: 'overlapOffset is supplied without overlapLimit.',
113
+ retryable: false,
114
+ recovery: 'Supply overlapLimit to enable paging, or omit overlapOffset for full overlaps.',
115
+ },
116
+ {
117
+ reason: 'overlaps_not_selected',
118
+ code: JsonRpcErrorCode.ValidationError,
119
+ when: 'Overlap paging is requested but sections excludes overlaps_with.',
120
+ retryable: false,
121
+ recovery: 'Include overlaps_with in sections or omit sections, then retry with overlapLimit.',
122
+ },
41
123
  {
42
124
  reason: 'database_mismatch',
43
125
  code: JsonRpcErrorCode.ValidationError,
@@ -81,14 +163,64 @@ export const interproGetEntry = tool('interpro_get_entry', {
81
163
  ...UPSTREAM_ERRORS,
82
164
  ],
83
165
  async handler(input, ctx) {
166
+ if (input.overlapOffset !== undefined && input.overlapLimit === undefined)
167
+ throw ctx.fail('overlap_limit_required');
168
+ if (input.overlapLimit !== undefined &&
169
+ input.sections &&
170
+ !input.sections.includes('overlaps_with'))
171
+ throw ctx.fail('overlaps_not_selected');
84
172
  const target = resolveEntry(input.accession, input.sourceDatabase);
85
173
  const service = getInterproService();
86
174
  const response = await service.request(service.begin(ctx), ['entry', target.sourceDatabase, target.accession], {}, detailSchema(EntryMetadataSchema), { missing: { reason: 'entry_not_found', ...target } });
87
175
  if (!response.data)
88
176
  throw ctx.fail('upstream_shape_invalid', 'Entry metadata response is missing.');
89
- const { metadata, notice } = projectWikipediaThumbnails(response.data.metadata, input.includeThumbnail, 'interpro_get_entry');
177
+ const sourceMetadata = response.data.metadata;
178
+ const selected = input.sections === undefined
179
+ ? undefined
180
+ : SECTIONS.filter((section) => input.sections?.includes(section));
181
+ const omittedSections = selected === undefined
182
+ ? undefined
183
+ : SECTIONS.filter((section) => !selected.includes(section) && Object.hasOwn(sourceMetadata, section));
184
+ const projected = { ...sourceMetadata };
185
+ for (const section of omittedSections ?? [])
186
+ delete projected[section];
187
+ const notices = [];
188
+ if (selected)
189
+ notices.push(`Selected sections: ${JSON.stringify(selected)}; omitted source sections: ${JSON.stringify(omittedSections)}. Core and unknown metadata are retained.`);
190
+ let overlapsPage;
191
+ if (input.overlapLimit !== undefined) {
192
+ const offset = input.overlapOffset ?? 0;
193
+ const overlaps = projected.overlaps_with;
194
+ if (overlaps === undefined || overlaps === null) {
195
+ overlapsPage = { available: false, offset };
196
+ notices.push('Overlap paging is unavailable because upstream overlaps_with is missing or null; no total is known.');
197
+ }
198
+ else {
199
+ if (!Array.isArray(overlaps))
200
+ throw ctx.fail('upstream_shape_invalid', 'Entry overlaps_with is not an array.');
201
+ const slice = overlaps.slice(offset, offset + Math.min(input.overlapLimit, overlaps.length));
202
+ projected.overlaps_with = slice;
203
+ const nextOffset = offset + slice.length;
204
+ const hasMore = nextOffset < overlaps.length;
205
+ ctx.enrich.total(overlaps.length);
206
+ overlapsPage = {
207
+ available: true,
208
+ total: overlaps.length,
209
+ offset,
210
+ returned: slice.length,
211
+ hasMore,
212
+ ...(hasMore ? { nextOffset } : {}),
213
+ };
214
+ notices.push(`Overlap page returned ${slice.length} of ${overlaps.length} records at offset ${offset}.`);
215
+ if (hasMore)
216
+ notices.push(`Continue with interpro_get_entry ${JSON.stringify({ ...target, includeThumbnail: input.includeThumbnail, ...(selected ? { sections: selected } : {}), overlapLimit: input.overlapLimit, overlapOffset: nextOffset })}.`);
217
+ }
218
+ }
219
+ const { metadata, notice } = projectWikipediaThumbnails(projected, input.includeThumbnail, 'interpro_get_entry');
90
220
  if (notice)
91
- ctx.enrich.notice(notice);
221
+ notices.push(notice);
222
+ if (notices.length)
223
+ ctx.enrich.notice(notices.join(' '));
92
224
  const readable = descriptionText(metadata.description);
93
225
  const entry = normalizeImages(metadata);
94
226
  if (readable)
@@ -98,6 +230,8 @@ export const interproGetEntry = tool('interpro_get_entry', {
98
230
  entry,
99
231
  url: `https://www.ebi.ac.uk/interpro/entry/${target.sourceDatabase}/${encodeURIComponent(target.accession)}/`,
100
232
  sourceUrl: response.sourceUrl,
233
+ ...(selected ? { sections: selected, omittedSections } : {}),
234
+ ...(overlapsPage ? { overlapsPage } : {}),
101
235
  };
102
236
  },
103
237
  format: formatInterpro,
@@ -1 +1 @@
1
- {"version":3,"file":"interpro-get-entry.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/interpro-get-entry.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,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,eAAe,EACf,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EACL,eAAe,EACf,YAAY,EACZ,yBAAyB,EACzB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAEzE,wEAAwE;AACxE,MAAM,CAAC,MAAM,gBAAgB,GAA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CAAC,IAAI,CAAC,wBAAwB,EAAE,qCAAqC,CAAC,CAAC;QAClF,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,0BAA0B,CACrD,QAAQ,CAAC,IAAI,CAAC,QAAQ,EACtB,KAAK,CAAC,gBAAgB,EACtB,oBAAoB,CACrB,CAAC;QACF,IAAI,MAAM;YAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,QAAQ;YAAE,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;QAC/C,OAAO;YACL,GAAG,MAAM;YACT,KAAK;YACL,GAAG,EAAE,wCAAwC,MAAM,CAAC,cAAc,IAAI,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG;YAC7G,SAAS,EAAE,QAAQ,CAAC,SAAS;SAC9B,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,cAAc;CACvB,CAAC,CAAC"}
1
+ {"version":3,"file":"interpro-get-entry.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/interpro-get-entry.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,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,eAAe,EACf,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EACL,eAAe,EACf,YAAY,EACZ,yBAAyB,EACzB,mBAA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CAAC,cAAc,IAAI,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG;YAC7G,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1C,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,cAAc;CACvB,CAAC,CAAC"}
@@ -9,6 +9,7 @@ export declare const interproGetProteinDomains: import("@cyanheads/mcp-ts-core")
9
9
  accession: z.ZodString;
10
10
  residuePosition: z.ZodOptional<z.ZodNumber>;
11
11
  includeExtraFeatures: z.ZodDefault<z.ZodBoolean>;
12
+ includeResidueAnnotations: z.ZodDefault<z.ZodBoolean>;
12
13
  cursor: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
13
14
  }, z.core.$strip>, z.ZodObject<{
14
15
  accession: z.ZodString;
@@ -69,9 +70,24 @@ export declare const interproGetProteinDomains: import("@cyanheads/mcp-ts-core")
69
70
  score: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
70
71
  }, z.core.$catchall<z.ZodJSONSchema>>>;
71
72
  }, z.core.$catchall<z.ZodJSONSchema>>>>;
73
+ residueAnnotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
74
+ accession: z.ZodString;
75
+ source_database: z.ZodString;
76
+ locations: z.ZodArray<z.ZodObject<{
77
+ fragments: z.ZodArray<z.ZodObject<{
78
+ start: z.ZodNumber;
79
+ end: z.ZodNumber;
80
+ 'dc-status': z.ZodOptional<z.ZodString>;
81
+ }, z.core.$catchall<z.ZodJSONSchema>>>;
82
+ representative: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
83
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
84
+ score: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
85
+ }, z.core.$catchall<z.ZodJSONSchema>>>;
86
+ }, z.core.$catchall<z.ZodJSONSchema>>>>;
72
87
  selection: z.ZodObject<{
73
88
  residuePosition: z.ZodOptional<z.ZodNumber>;
74
89
  includeExtraFeatures: z.ZodBoolean;
90
+ includeResidueAnnotations: z.ZodOptional<z.ZodLiteral<true>>;
75
91
  }, z.core.$strip>;
76
92
  coverage: z.ZodObject<{
77
93
  totalMatches: z.ZodNumber;
@@ -79,6 +95,8 @@ export declare const interproGetProteinDomains: import("@cyanheads/mcp-ts-core")
79
95
  returnedMatches: z.ZodNumber;
80
96
  totalFeatures: z.ZodOptional<z.ZodNumber>;
81
97
  returnedFeatures: z.ZodOptional<z.ZodNumber>;
98
+ totalResidueAnnotations: z.ZodOptional<z.ZodNumber>;
99
+ returnedResidueAnnotations: z.ZodOptional<z.ZodNumber>;
82
100
  complete: z.ZodBoolean;
83
101
  hasMore: z.ZodBoolean;
84
102
  nextCursor: z.ZodOptional<z.ZodString>;
@@ -88,9 +106,9 @@ export declare const interproGetProteinDomains: import("@cyanheads/mcp-ts-core")
88
106
  }, z.core.$strip>, readonly [{
89
107
  readonly reason: "retry_deadline_exceeded";
90
108
  readonly code: JsonRpcErrorCode.Timeout;
91
- readonly when: "The shared fifty-second budget expires across protein metadata, match pages, and extra features.";
109
+ readonly when: "The shared fifty-second budget expires across metadata, match pages, extra features, and residue rules.";
92
110
  readonly retryable: true;
93
- readonly recovery: "Retry interpro_get_protein_domains after waiting; omit extra features when they are not needed.";
111
+ readonly recovery: "Retry interpro_get_protein_domains after waiting; omit optional annotations when they are not needed.";
94
112
  readonly thrownBy: "service";
95
113
  }, {
96
114
  readonly reason: "invalid_cursor";
@@ -1 +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"}
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;AAmLjE,gGAAgG;AAChG,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoYpC,CAAC"}
@@ -8,7 +8,7 @@ import { BUDGET_LABEL, fitWithinBudget, jsonByteLength, RESPONSE_BYTE_BUDGET, }
8
8
  import { compareText, continuation, cursorScope, decodePositionCursor, encodePositionCursor, } from '../../../services/interpro/cursors.js';
9
9
  import { formatInterpro, normalizeImages } from '../../../services/interpro/format.js';
10
10
  import { getInterproService } from '../../../services/interpro/interpro-service.js';
11
- import { detailSchema, ExtraFeaturesSchema, isAccession, listSchema, MatchSchema, optionalString, ProteinAccessionSchema, ProteinMetadataSchema, } from '../../../services/interpro/schemas.js';
11
+ import { detailSchema, ExtraFeaturesSchema, isAccession, listSchema, MatchSchema, optionalString, ProteinAccessionSchema, ProteinMetadataSchema, ResidueAnnotationsSchema, } from '../../../services/interpro/schemas.js';
12
12
  import { UPSTREAM_ERRORS } from '../../../services/interpro/upstream-errors.js';
13
13
  const OPERATION = 'interpro_get_protein_domains';
14
14
  const PAGE_SIZE = 200;
@@ -21,13 +21,17 @@ const SelectionSchema = z.object({
21
21
  .optional()
22
22
  .describe('Selected 1-based inclusive residue position.'),
23
23
  includeExtraFeatures: z.boolean().describe('Whether extra predicted features were requested.'),
24
+ includeResidueAnnotations: z
25
+ .literal(true)
26
+ .optional()
27
+ .describe('Present only when residue rules were requested.'),
24
28
  });
25
29
  const CoverageSchema = z.object({
26
30
  totalMatches: z
27
31
  .number()
28
32
  .int()
29
33
  .nonnegative()
30
- .describe('Upstream unfiltered total match count; a segment holding only extra features repeats the count the match list reported.'),
34
+ .describe('Upstream unfiltered total match count; extra-feature-only and residue-rule-only segments repeat the count reported by the match list.'),
31
35
  scannedMatches: z
32
36
  .number()
33
37
  .int()
@@ -50,22 +54,34 @@ const CoverageSchema = z.object({
50
54
  .nonnegative()
51
55
  .optional()
52
56
  .describe('Extra features in this segment; present with extraFeatures.'),
57
+ totalResidueAnnotations: z
58
+ .number()
59
+ .int()
60
+ .nonnegative()
61
+ .optional()
62
+ .describe('Selected residue rules; present only when the residue stage is reached.'),
63
+ returnedResidueAnnotations: z
64
+ .number()
65
+ .int()
66
+ .nonnegative()
67
+ .optional()
68
+ .describe('Whole residue rules returned in this segment.'),
53
69
  complete: z
54
70
  .boolean()
55
- .describe('True only when this call starts without a cursor and returns the whole map: every match and every requested extra feature.'),
71
+ .describe('True only when this call starts without a cursor and returns every match, requested extra feature, and requested residue rule.'),
56
72
  hasMore: z
57
73
  .boolean()
58
- .describe('Whether another segment remains, holding more matches or requested extra features.'),
74
+ .describe('Whether another segment remains, holding matches, requested extras, or requested residue rules.'),
59
75
  nextCursor: z
60
76
  .string()
61
77
  .optional()
62
- .describe('Opaque cursor resuming at the next whole match or extra feature, for the same protein and selection.'),
78
+ .describe('Opaque cursor resuming at the next whole match, extra feature, or residue rule for the same protein and selection.'),
63
79
  });
64
80
  /**
65
81
  * Where a continuation resumes: `skip` records into an upstream match page (`page` is that
66
82
  * 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.
83
+ * the feature list that follows the last match, or `residues` selected rules after the extras.
84
+ * `after` names the last record an earlier segment covered, so changed lists are rejected.
69
85
  */
70
86
  const PositionSchema = z.union([
71
87
  z
@@ -85,6 +101,14 @@ const PositionSchema = z.union([
85
101
  })
86
102
  .strict()
87
103
  .refine((point) => point.features > 0 === (point.after !== undefined)),
104
+ z
105
+ .object({
106
+ residues: z.number().int().nonnegative(),
107
+ after: z.string().min(1).optional(),
108
+ totalMatches: z.number().int().nonnegative(),
109
+ })
110
+ .strict()
111
+ .refine((point) => point.residues > 0 === (point.after !== undefined)),
88
112
  ]);
89
113
  function contains(locations, position) {
90
114
  return locations.some((location) => location.fragments.some((fragment) => fragment.start <= position && position <= fragment.end));
@@ -101,7 +125,7 @@ function byCoordinate(left, right) {
101
125
  /** Map signatures to sequence coordinates in budget-bounded segments with explicit coverage. */
102
126
  export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
103
127
  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.',
128
+ description: 'Retrieve InterPro and member-signature matches on a canonical UniProt protein, preserving every location and discontinuous fragment. Optionally select records covering a residue, include extra predicted features, and include functional residue rules with provenance. Budgeted segments hold whole records in order: matches, requested extras, then requested residue rules sorted by key. The first segment carries protein metadata; continue coverage.nextCursor until hasMore is false.',
105
129
  annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
106
130
  auth: ['tool:interpro_get_protein_domains:read'],
107
131
  input: z.object({
@@ -116,7 +140,11 @@ export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
116
140
  .boolean()
117
141
  .default(false)
118
142
  .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.'),
143
+ includeResidueAnnotations: z
144
+ .boolean()
145
+ .default(false)
146
+ .describe('Include complete functional residue rules after matches and requested extras; defaults to false.'),
147
+ cursor: optionalString(z.string().trim().max(4096)).describe('Opaque coverage.nextCursor with unchanged accession, residuePosition, includeExtraFeatures, and includeResidueAnnotations.'),
120
148
  }),
121
149
  output: z.object({
122
150
  accession: z.string().describe('Canonical UniProt accession.'),
@@ -125,8 +153,9 @@ export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
125
153
  .array(MatchSchema.describe('Complete entry match record.'))
126
154
  .describe('Whole selected match records in this segment, sorted by earliest coordinate then accession; a match is never split across segments.'),
127
155
  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.'),
156
+ residueAnnotations: ResidueAnnotationsSchema.optional().describe('Whole selected residue rules sorted by key; {} means the stage was reached with no selected rules. Omitted when unrequested or unreached.'),
157
+ selection: SelectionSchema.describe('Applied residue, extra-feature, and residue-rule selection.'),
158
+ coverage: CoverageSchema.describe('Where this segment sits in the protein map: matches, requested extra features, then requested residue rules.'),
130
159
  url: z.string().describe('Canonical protein website URL.'),
131
160
  sourceUrl: z.string().describe('Official protein API source URL.'),
132
161
  }),
@@ -146,9 +175,9 @@ export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
146
175
  {
147
176
  reason: 'retry_deadline_exceeded',
148
177
  code: JsonRpcErrorCode.Timeout,
149
- when: 'The shared fifty-second budget expires across protein metadata, match pages, and extra features.',
178
+ when: 'The shared fifty-second budget expires across metadata, match pages, extra features, and residue rules.',
150
179
  retryable: true,
151
- recovery: 'Retry interpro_get_protein_domains after waiting; omit extra features when they are not needed.',
180
+ recovery: 'Retry interpro_get_protein_domains after waiting; omit optional annotations when they are not needed.',
152
181
  thrownBy: 'service',
153
182
  },
154
183
  {
@@ -198,12 +227,15 @@ export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
198
227
  const selection = {
199
228
  ...(residue !== undefined ? { residuePosition: residue } : {}),
200
229
  includeExtraFeatures: input.includeExtraFeatures,
230
+ ...(input.includeResidueAnnotations ? { includeResidueAnnotations: true } : {}),
201
231
  };
202
232
  const scope = { accession, ...selection };
203
233
  const start = decodePositionCursor(input.cursor, OPERATION, scope, PositionSchema);
204
234
  const stale = () => ctx.fail('invalid_cursor', 'Cursor no longer matches the InterPro records it resumes inside.');
205
235
  if (start && 'features' in start && !input.includeExtraFeatures)
206
236
  throw stale();
237
+ if (start && 'residues' in start && !input.includeResidueAnnotations)
238
+ throw stale();
207
239
  const resumed = start !== undefined;
208
240
  const covers = (locations) => residue === undefined || contains(locations, residue);
209
241
  const service = getInterproService();
@@ -214,11 +246,12 @@ export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
214
246
  const protein = normalizeImages(detail.data.metadata);
215
247
  if (residue !== undefined && residue > protein.length)
216
248
  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. */
249
+ /** Whole candidate items: matches, selected extra features, then selected residue rules. */
218
250
  const items = [];
219
251
  let scanned = 0;
220
- let totalMatches = start && 'features' in start ? start.totalMatches : 0;
252
+ let totalMatches = start && !('skip' in start) ? start.totalMatches : 0;
221
253
  let totalFeatures;
254
+ let totalResidueAnnotations;
222
255
  /** Where the walk resumes after the last gathered item; undefined once the walk ends. */
223
256
  let end;
224
257
  const segment = (count) => {
@@ -226,18 +259,24 @@ export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
226
259
  const resume = stop ? stop.at : end;
227
260
  const matches = [];
228
261
  const features = [];
262
+ const residues = [];
229
263
  for (const item of items.slice(0, count))
230
264
  if (item.kind === 'match')
231
265
  matches.push(item.match);
232
- else
266
+ else if (item.kind === 'feature')
233
267
  features.push([item.key, item.feature]);
268
+ else
269
+ residues.push([item.key, item.rule]);
234
270
  const featureTotal = totalFeatures;
235
- const reachedFeatures = featureTotal !== undefined && (features.length > 0 || resume === undefined);
271
+ const reachedFeatures = featureTotal !== undefined &&
272
+ (features.length > 0 || resume === undefined || 'residues' in resume);
273
+ const reachedResidues = totalResidueAnnotations !== undefined && (residues.length > 0 || resume === undefined);
236
274
  return {
237
275
  accession,
238
276
  ...(resumed ? {} : { protein }),
239
277
  matches: matches.toSorted(byCoordinate),
240
278
  ...(reachedFeatures ? { extraFeatures: Object.fromEntries(features) } : {}),
279
+ ...(reachedResidues ? { residueAnnotations: Object.fromEntries(residues) } : {}),
241
280
  selection,
242
281
  coverage: {
243
282
  totalMatches,
@@ -246,6 +285,9 @@ export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
246
285
  ...(reachedFeatures
247
286
  ? { totalFeatures: featureTotal, returnedFeatures: features.length }
248
287
  : {}),
288
+ ...(reachedResidues
289
+ ? { totalResidueAnnotations, returnedResidueAnnotations: residues.length }
290
+ : {}),
249
291
  complete: !resumed && resume === undefined,
250
292
  hasMore: resume !== undefined,
251
293
  ...(resume ? { nextCursor: encodePositionCursor(OPERATION, scope, resume) } : {}),
@@ -293,7 +335,7 @@ export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
293
335
  break;
294
336
  }
295
337
  }
296
- if (input.includeExtraFeatures && end === undefined) {
338
+ if (input.includeExtraFeatures && !(start && 'residues' in start) && end === undefined) {
297
339
  // Read extras only when the matches fit beside the cursor that would resume at them.
298
340
  end = { features: 0, totalMatches };
299
341
  if (!overflows()) {
@@ -325,20 +367,53 @@ export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
325
367
  }
326
368
  }
327
369
  }
370
+ if (input.includeResidueAnnotations && end === undefined) {
371
+ end = { residues: 0, totalMatches };
372
+ if (!overflows()) {
373
+ end = undefined;
374
+ const response = await service.request(call, ['protein', 'uniprot', accession], { residues: '' }, ResidueAnnotationsSchema);
375
+ if (!response.data)
376
+ throw ctx.fail('upstream_shape_invalid', 'Residue annotation response is missing.');
377
+ const selected = Object.entries(normalizeImages(response.data))
378
+ .filter(([, rule]) => covers(rule.locations))
379
+ .toSorted(([a], [b]) => compareText(a, b));
380
+ const resumeAt = start && 'residues' in start ? start : undefined;
381
+ const skip = resumeAt?.residues ?? 0;
382
+ if (skip > 0 && (skip >= selected.length || selected[skip - 1]?.[0] !== resumeAt?.after))
383
+ throw stale();
384
+ totalResidueAnnotations = selected.length;
385
+ for (let index = skip; index < selected.length; index++) {
386
+ const [key, rule] = selected[index];
387
+ items.push({
388
+ kind: 'residue',
389
+ key,
390
+ rule,
391
+ scannedBefore: scanned,
392
+ at: {
393
+ residues: index,
394
+ ...(index ? { after: selected[index - 1][0] } : {}),
395
+ totalMatches,
396
+ },
397
+ });
398
+ }
399
+ }
400
+ }
328
401
  const { count, output, oversized } = fitWithinBudget(items.length, segment);
329
402
  const { coverage } = output;
330
403
  const stop = items[count];
331
404
  const notices = [];
332
405
  if (oversized) {
333
406
  const only = items[0];
334
- const [named, unnamed, id] = only.kind === 'feature'
335
- ? ['Extra feature', 'This extra feature', only.key]
407
+ const [named, unnamed, id] = only.kind !== 'match'
408
+ ? only.kind === 'feature'
409
+ ? ['Extra feature', 'This extra feature', only.key]
410
+ : ['Residue rule', 'This residue rule', only.key]
336
411
  : ['Match', 'This match', only.match.metadata.accession];
337
412
  notices.push(`${isAccession(id) ? `${named} ${id}` : unnamed} cannot be split, so this segment holds it alone and exceeds the ${BUDGET_LABEL}.`);
338
413
  }
339
414
  if (coverage.nextCursor) {
340
415
  const reason = stop
341
- ? ` and stopped at the ${BUDGET_LABEL} before the next whole ${stop.kind === 'match' ? 'match' : 'extra feature'}`
416
+ ? ` and stopped at the ${BUDGET_LABEL} before the next whole ${stop.kind === 'match' ? 'match' : stop.kind === 'feature' ? 'extra feature' : 'residue rule'}`
342
417
  : oversized
343
418
  ? ''
344
419
  : ` and reached the ${MAX_PAGES}-page read limit after ${coverage.scannedMatches} match records`;
@@ -346,13 +421,14 @@ export const interproGetProteinDomains = tool('interpro_get_protein_domains', {
346
421
  accession,
347
422
  ...(residue !== undefined ? { residuePosition: residue } : {}),
348
423
  ...(input.includeExtraFeatures ? { includeExtraFeatures: true } : {}),
424
+ ...(input.includeResidueAnnotations ? { includeResidueAnnotations: true } : {}),
349
425
  cursor: coverage.nextCursor,
350
426
  };
351
427
  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
428
  }
353
429
  else if (resumed)
354
430
  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
431
+ (coverage.returnedMatches || !('skip' in start)
356
432
  ? ''
357
433
  : ' No match was selected in this segment.'));
358
434
  else if (!coverage.returnedMatches)