mcp-sequential-research 1.0.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.
package/src/schema.ts ADDED
@@ -0,0 +1,303 @@
1
+ /**
2
+ * Zod schemas for MCP Sequential Research tools
3
+ *
4
+ * Defines input/output validation for:
5
+ * - sequential_research_plan
6
+ * - sequential_research_compile
7
+ */
8
+
9
+ import { z } from "zod";
10
+
11
+ // ============================================================================
12
+ // Common Schemas
13
+ // ============================================================================
14
+
15
+ /**
16
+ * Citation reference for tracking source provenance
17
+ */
18
+ export const CitationSchema = z.object({
19
+ id: z.string().describe("Unique citation identifier (e.g., [1], [src-001])"),
20
+ source_type: z.enum(["web", "document", "api", "database", "manual", "patent"]).describe("Type of source"),
21
+ title: z.string().describe("Title or name of the source"),
22
+ url: z.string().optional().describe("URL if applicable"),
23
+ accessed_date: z.string().optional().describe("ISO date when source was accessed"),
24
+ excerpt: z.string().optional().describe("Relevant excerpt from the source"),
25
+ // Patent-specific fields
26
+ patent_number: z.string().optional().describe("Patent number (e.g., US11123456B2)"),
27
+ assignee: z.string().optional().describe("Patent assignee/owner"),
28
+ filing_date: z.string().optional().describe("Patent filing date"),
29
+ priority_date: z.string().optional().describe("Patent priority date"),
30
+ claims_count: z.number().optional().describe("Number of claims"),
31
+ });
32
+
33
+ export type Citation = z.infer<typeof CitationSchema>;
34
+
35
+ // ============================================================================
36
+ // Plan Tool Schemas
37
+ // ============================================================================
38
+
39
+ /**
40
+ * Input for sequential_research_plan tool
41
+ */
42
+ export const PlanInputSchema = z.object({
43
+ topic: z.string().min(1).describe("The research topic or question to investigate"),
44
+ depth: z.enum(["shallow", "standard", "deep"]).default("standard").describe(
45
+ "Research depth: shallow (3-5 queries), standard (5-10 queries), deep (10-20 queries)"
46
+ ),
47
+ focus_areas: z.array(z.string()).optional().describe(
48
+ "Specific aspects to focus on (e.g., ['technical details', 'market analysis'])"
49
+ ),
50
+ constraints: z.array(z.string()).optional().describe(
51
+ "Research constraints or exclusions (e.g., ['no paywalled sources', 'english only'])"
52
+ ),
53
+ output_format: z.enum(["markdown", "json", "structured"]).default("markdown").describe(
54
+ "Desired format for the final compiled output"
55
+ ),
56
+ });
57
+
58
+ export type PlanInput = z.infer<typeof PlanInputSchema>;
59
+
60
+ /**
61
+ * A single research query with extraction goals
62
+ */
63
+ export const ResearchQuerySchema = z.object({
64
+ query_id: z.string().describe("Unique identifier for this query (e.g., q1, q2)"),
65
+ query_text: z.string().describe("The actual search query or question"),
66
+ query_type: z.enum([
67
+ // General query types
68
+ "definition", // What is X?
69
+ "comparison", // How does X compare to Y?
70
+ "enumeration", // List all X that...
71
+ "procedure", // How to do X?
72
+ "causation", // Why does X happen?
73
+ "evidence", // What evidence supports X?
74
+ "current_state", // What is the current state of X?
75
+ "historical", // History of X
76
+ "prediction", // Future of X
77
+ "opinion", // Expert opinions on X
78
+ // Patent-grade query types
79
+ "patent_broad", // Broad concept patent search
80
+ "patent_synonyms", // Alternative terminology/synonyms
81
+ "patent_problem_benefit", // Problem-solution framing
82
+ "patent_competitor", // Competitor/assignee search
83
+ "patent_limitation", // Component-level limitations (narrow novelty)
84
+ // Web query types for prior art
85
+ "web_academic", // Academic sources (.edu, .pdf)
86
+ "web_vendor", // Vendor documentation
87
+ "web_opensource", // OSS repositories (GitHub, GitLab)
88
+ "web_conference", // Conference papers (IEEE, ACM, arXiv)
89
+ ]).describe("Type of query for extraction strategy"),
90
+ query_family: z.enum(["general", "patent", "web"]).default("general").describe(
91
+ "Query family for source targeting"
92
+ ),
93
+ extraction_goals: z.array(z.string()).describe(
94
+ "Specific pieces of information to extract from results"
95
+ ),
96
+ priority: z.enum(["critical", "high", "medium", "low"]).default("medium").describe(
97
+ "Priority level for this query"
98
+ ),
99
+ depends_on: z.array(z.string()).optional().describe(
100
+ "Query IDs that must complete before this one"
101
+ ),
102
+ search_modifiers: z.array(z.string()).optional().describe(
103
+ "Search modifiers (e.g., 'site:.edu', 'filetype:pdf', 'assignee:Google')"
104
+ ),
105
+ });
106
+
107
+ export type ResearchQuery = z.infer<typeof ResearchQuerySchema>;
108
+
109
+ /**
110
+ * Schema definition for expected raw results
111
+ */
112
+ export const RawResultSchemaDefinition = z.object({
113
+ query_id: z.string().describe("The query this schema applies to"),
114
+ required_fields: z.array(z.object({
115
+ field_name: z.string(),
116
+ field_type: z.enum(["string", "number", "boolean", "array", "object"]),
117
+ description: z.string(),
118
+ required: z.boolean().default(true),
119
+ })).describe("Required fields in the raw result"),
120
+ example: z.record(z.unknown()).optional().describe("Example of expected result structure"),
121
+ });
122
+
123
+ export type RawResultSchemaDefinition = z.infer<typeof RawResultSchemaDefinition>;
124
+
125
+ /**
126
+ * Output from sequential_research_plan tool
127
+ */
128
+ export const PlanOutputSchema = z.object({
129
+ plan_id: z.string().describe("Unique identifier for this research plan"),
130
+ topic: z.string().describe("Original research topic"),
131
+ created_at: z.string().describe("ISO timestamp when plan was created"),
132
+ summary: z.string().describe("Brief summary of the research plan"),
133
+ queries: z.array(ResearchQuerySchema).describe("Ordered list of research queries"),
134
+ result_schemas: z.array(RawResultSchemaDefinition).describe(
135
+ "Expected schema for each query's raw results"
136
+ ),
137
+ execution_order: z.array(z.array(z.string())).describe(
138
+ "Grouped query IDs - each group can run in parallel, groups run sequentially"
139
+ ),
140
+ estimated_sources: z.number().describe("Estimated number of sources to consult"),
141
+ metadata: z.object({
142
+ depth: z.string(),
143
+ focus_areas: z.array(z.string()),
144
+ constraints: z.array(z.string()),
145
+ output_format: z.string(),
146
+ }).describe("Original input parameters preserved for compilation"),
147
+ });
148
+
149
+ export type PlanOutput = z.infer<typeof PlanOutputSchema>;
150
+
151
+ // ============================================================================
152
+ // Compile Tool Schemas
153
+ // ============================================================================
154
+
155
+ /**
156
+ * Raw result from executing a single query
157
+ */
158
+ export const RawResultSchema = z.object({
159
+ query_id: z.string().describe("Query ID this result corresponds to"),
160
+ success: z.boolean().describe("Whether the query execution succeeded"),
161
+ data: z.record(z.unknown()).optional().describe("Extracted data matching the result schema"),
162
+ sources: z.array(CitationSchema).optional().describe("Sources consulted for this query"),
163
+ error: z.string().optional().describe("Error message if success is false"),
164
+ execution_notes: z.string().optional().describe("Notes about the execution"),
165
+ });
166
+
167
+ export type RawResult = z.infer<typeof RawResultSchema>;
168
+
169
+ /**
170
+ * Input for sequential_research_compile tool
171
+ */
172
+ export const CompileInputSchema = z.object({
173
+ plan: PlanOutputSchema.describe("The research plan to compile results for"),
174
+ raw_results: z.array(RawResultSchema).describe("Raw results from executing the plan queries"),
175
+ include_sources: z.boolean().default(true).describe("Include sources section in output"),
176
+ include_methodology: z.boolean().default(false).describe("Include methodology section"),
177
+ citation_style: z.enum(["inline", "footnote", "endnote"]).default("inline").describe(
178
+ "How to format citations in the output"
179
+ ),
180
+ });
181
+
182
+ export type CompileInput = z.infer<typeof CompileInputSchema>;
183
+
184
+ /**
185
+ * A section in the compiled report
186
+ */
187
+ export const ReportSectionSchema = z.object({
188
+ heading: z.string().describe("Section heading"),
189
+ level: z.number().min(1).max(4).describe("Heading level (1-4)"),
190
+ content: z.string().describe("Section content in markdown"),
191
+ citations_used: z.array(z.string()).describe("Citation IDs used in this section"),
192
+ });
193
+
194
+ export type ReportSection = z.infer<typeof ReportSectionSchema>;
195
+
196
+ /**
197
+ * Prior art cluster for grouping related sources
198
+ */
199
+ export const PriorArtClusterSchema = z.object({
200
+ cluster_id: z.string().describe("Unique cluster identifier"),
201
+ theme: z.string().describe("Thematic description of the cluster"),
202
+ source_ids: z.array(z.string()).describe("Citation IDs in this cluster"),
203
+ relevance: z.enum(["high", "medium", "low"]).describe("Relevance to the research topic"),
204
+ overlap_notes: z.string().optional().describe("Notes on overlap with target claims"),
205
+ });
206
+
207
+ export type PriorArtCluster = z.infer<typeof PriorArtClusterSchema>;
208
+
209
+ /**
210
+ * Claim risk flag for potential novelty issues
211
+ */
212
+ export const ClaimRiskFlagSchema = z.object({
213
+ risk_id: z.string().describe("Unique risk identifier"),
214
+ severity: z.enum(["critical", "high", "medium", "low"]).describe("Risk severity"),
215
+ category: z.enum([
216
+ "anticipation", // Prior art fully discloses the claim
217
+ "obviousness", // Combination of references makes claim obvious
218
+ "enablement", // Specification may not enable full scope
219
+ "written_description", // Claim may lack written description support
220
+ "indefiniteness", // Claim terms may be unclear
221
+ ]).describe("Type of claim risk"),
222
+ description: z.string().describe("Description of the risk"),
223
+ affected_elements: z.array(z.string()).optional().describe("Claim elements affected"),
224
+ blocking_sources: z.array(z.string()).optional().describe("Citation IDs that create this risk"),
225
+ mitigation: z.string().optional().describe("Suggested mitigation strategy"),
226
+ });
227
+
228
+ export type ClaimRiskFlag = z.infer<typeof ClaimRiskFlagSchema>;
229
+
230
+ /**
231
+ * Novelty gap suggestion for differentiation
232
+ */
233
+ export const NoveltyGapSchema = z.object({
234
+ gap_id: z.string().describe("Unique gap identifier"),
235
+ limitation_type: z.enum([
236
+ "structural", // Physical/structural difference
237
+ "functional", // Functional difference
238
+ "material", // Material composition difference
239
+ "process", // Method step difference
240
+ "parameter", // Numerical parameter difference
241
+ "combination", // Novel combination of known elements
242
+ ]).describe("Type of limitation"),
243
+ description: z.string().describe("Description of the potential differentiation"),
244
+ confidence: z.enum(["high", "medium", "low"]).describe("Confidence in novelty"),
245
+ supporting_evidence: z.array(z.string()).optional().describe("Citation IDs supporting this gap"),
246
+ claim_language_suggestion: z.string().optional().describe("Suggested claim language"),
247
+ });
248
+
249
+ export type NoveltyGap = z.infer<typeof NoveltyGapSchema>;
250
+
251
+ /**
252
+ * Output from sequential_research_compile tool
253
+ */
254
+ export const CompileOutputSchema = z.object({
255
+ report_id: z.string().describe("Unique identifier for this report"),
256
+ plan_id: z.string().describe("ID of the plan this report was compiled from"),
257
+ title: z.string().describe("Report title"),
258
+ compiled_at: z.string().describe("ISO timestamp when report was compiled"),
259
+ executive_summary: z.string().describe("Brief executive summary"),
260
+ sections: z.array(ReportSectionSchema).describe("Report sections"),
261
+ markdown_report: z.string().describe("Complete markdown-formatted report"),
262
+ sources: z.array(CitationSchema).describe("Consolidated list of all sources"),
263
+ statistics: z.object({
264
+ queries_executed: z.number(),
265
+ queries_succeeded: z.number(),
266
+ queries_failed: z.number(),
267
+ total_sources: z.number(),
268
+ word_count: z.number(),
269
+ patent_sources: z.number().optional(),
270
+ web_sources: z.number().optional(),
271
+ }).describe("Report statistics"),
272
+ // Patent-grade analysis outputs
273
+ prior_art_clusters: z.array(PriorArtClusterSchema).optional().describe(
274
+ "Grouped prior art by theme/relevance"
275
+ ),
276
+ claim_risk_flags: z.array(ClaimRiskFlagSchema).optional().describe(
277
+ "Identified risks to patentability"
278
+ ),
279
+ novelty_gaps: z.array(NoveltyGapSchema).optional().describe(
280
+ "Suggested limitations for differentiation"
281
+ ),
282
+ warnings: z.array(z.string()).optional().describe("Any warnings generated during compilation"),
283
+ });
284
+
285
+ export type CompileOutput = z.infer<typeof CompileOutputSchema>;
286
+
287
+ // ============================================================================
288
+ // Tool Definitions for MCP
289
+ // ============================================================================
290
+
291
+ /**
292
+ * JSON Schema representations for MCP tool definitions
293
+ */
294
+ export const toolSchemas = {
295
+ sequential_research_plan: {
296
+ input: PlanInputSchema,
297
+ output: PlanOutputSchema,
298
+ },
299
+ sequential_research_compile: {
300
+ input: CompileInputSchema,
301
+ output: CompileOutputSchema,
302
+ },
303
+ } as const;
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022"],
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "declaration": true,
14
+ "declarationMap": true,
15
+ "sourceMap": true,
16
+ "resolveJsonModule": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "noImplicitReturns": true,
20
+ "noFallthroughCasesInSwitch": true
21
+ },
22
+ "include": ["src/**/*"],
23
+ "exclude": ["node_modules", "dist"]
24
+ }