telique-mcp 1.0.8 → 1.0.10

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/dist/index.js CHANGED
@@ -1,15 +1,26 @@
1
1
  #!/usr/bin/env node
2
- import { stdin } from "node:process";
3
2
  const subcommand = process.argv[2];
4
- // If run with "setup" arg, or directly in a terminal (not piped by an MCP client),
5
- // launch the interactive setup flow.
6
- const isInteractiveTerminal = subcommand !== "serve" && stdin.isTTY === true;
7
- if (subcommand === "setup" || isInteractiveTerminal) {
3
+ if (subcommand === "setup") {
4
+ // Explicit setup command
8
5
  const { runSetup } = await import("./setup.js");
9
6
  await runSetup();
10
7
  }
8
+ else if (!subcommand && process.stdin.isTTY && !process.env.MCP_CLIENT) {
9
+ // No args + interactive terminal + not spawned by an MCP client.
10
+ // Show a short help message pointing to setup.
11
+ console.log(`
12
+ telique-mcp v${(await import("./version.js")).VERSION}
13
+
14
+ Usage:
15
+ telique-mcp setup Interactive setup wizard
16
+ telique-mcp MCP server (stdio) — used by MCP clients
17
+
18
+ Run 'telique-mcp setup' to configure your API key and register
19
+ with your MCP clients (Claude, Cursor, Copilot, Codex, ChatGPT).
20
+ `);
21
+ }
11
22
  else {
12
- // MCP server mode — stdin is piped JSON-RPC from the MCP client
23
+ // MCP server mode — default when spawned by an MCP client
13
24
  const { McpServer } = await import("@modelcontextprotocol/sdk/server/mcp.js");
14
25
  const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
15
26
  const { TeliqueClient } = await import("./client.js");
@@ -20,6 +31,7 @@ else {
20
31
  const { registerCnamTools } = await import("./tools/cnam.js");
21
32
  const { registerLergTools } = await import("./tools/lerg.js");
22
33
  const { registerGraphqlTools } = await import("./tools/graphql.js");
34
+ const { registerKnowledge } = await import("./knowledge.js");
23
35
  const { registerCompositeTools } = await import("./tools/composite.js");
24
36
  const config = loadConfig();
25
37
  const client = new TeliqueClient(config);
@@ -34,6 +46,8 @@ else {
34
46
  registerLergTools(server, client);
35
47
  registerGraphqlTools(server, client);
36
48
  registerCompositeTools(server, client);
49
+ registerKnowledge(server);
37
50
  const transport = new StdioServerTransport();
38
51
  await server.connect(transport);
39
52
  }
53
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerKnowledge(server: McpServer): void;
@@ -0,0 +1,250 @@
1
+ export function registerKnowledge(server) {
2
+ server.prompt("telique-guide", "Comprehensive guide to Telique telecom APIs — LERG vs LSMS data boundary, routing lookup patterns, LERG table reference, CPR interpretation, CNAM, DNO, and common mistakes to avoid. Load this before answering telecom questions.", () => ({
3
+ messages: [
4
+ {
5
+ role: "user",
6
+ content: {
7
+ type: "text",
8
+ text: TELIQUE_KNOWLEDGE,
9
+ },
10
+ },
11
+ ],
12
+ }));
13
+ }
14
+ const TELIQUE_KNOWLEDGE = `# Telique Telecom API Knowledge Base
15
+
16
+ You have access to 13 Telique tools for querying live telecom data. NEVER guess carrier names, LRNs, routing data, or CNAM — always query the API.
17
+
18
+ ---
19
+
20
+ ## CRITICAL: LERG vs LSMS — Two Different Databases
21
+
22
+ **LERG** = Static telecom infrastructure reference (updated monthly from iconectiv BIRRDS)
23
+ - NPA-NXX assignments, switches, tandems, homing arrangements, rate centers, LATAs, carrier names by OCN
24
+ - 27 tables. NO individual phone number data.
25
+ - Query with: \`lerg_query\`, \`lerg_complex_query\`, \`lerg_tandem\`, \`lerg_table_info\`, or \`graphql_query(service="lerg")\`
26
+
27
+ **LSMS** = Live NPAC porting data (refreshed within minutes)
28
+ - Phone number ownership (SPID), LRN assignments, porting state
29
+ - NO routing infrastructure (no tandems, switches, homing, rate centers, OCN names)
30
+ - Query with: \`lrn_lookup\`, \`lrn_relationship_query\`, or \`graphql_query(service="lsms")\`
31
+
32
+ | Data Type | Database | Tool |
33
+ |-----------|----------|------|
34
+ | Tandem switches | **LERG** | \`lerg_tandem\` |
35
+ | Switch/CLLI details | **LERG** | \`lerg_query\` on lerg_7 |
36
+ | Homing arrangements | **LERG** | \`lerg_query\` on lerg_7_sha |
37
+ | NPA-NXX routing (OCN, switch, LATA, rate center) | **LERG** | \`lerg_query\` on lerg_6 |
38
+ | Carrier/OCN names | **LERG** | \`lerg_query\` on lerg_1 |
39
+ | Current TN ownership (SPID) | **LSMS** | \`lrn_lookup\` |
40
+ | Current LRN for a TN | **LSMS** | \`lrn_lookup\` |
41
+ | Porting state | **LSMS** | \`lrn_relationship_query\` or GraphQL |
42
+
43
+ ---
44
+
45
+ ## CRITICAL: Always Dip the LRN First
46
+
47
+ A ported phone number's NPA-NXX often differs from its LRN's NPA-NXX. For ANY routing question about a specific phone number:
48
+
49
+ 1. **\`lrn_lookup\`** → get the LRN and SPID
50
+ 2. Extract NPA-NXX from the **LRN** (first 3 digits = NPA, next 3 = NXX)
51
+ 3. Use the **LRN's** NPA-NXX for all LERG lookups
52
+
53
+ **Example:** TN 303-629-8301
54
+ - WRONG: Look up 303-629 in LERG → returns the original carrier's data (before porting)
55
+ - CORRECT: \`lrn_lookup("3036298301")\` → LRN = 7207081999 → look up 720-708 in LERG → returns current carrier
56
+
57
+ This applies to: tandem, switch, LATA, OCN, rate center — anything keyed by NPA-NXX.
58
+
59
+ ### The Golden Pattern for Routing Questions
60
+
61
+ \`\`\`
62
+ Step 1: lrn_lookup({phone_number}) → get LRN and SPID
63
+ Step 2: Extract NPA (first 3 digits of LRN) and NXX (next 3 digits of LRN)
64
+ Step 3: Use LRN's NPA-NXX for LERG queries:
65
+ - lerg_tandem({npa, nxx}) → tandem switch
66
+ - lerg_query("lerg_6", ..., "npa={npa}&nxx={nxx}") → OCN, switch, LATA, rate center
67
+ - lerg_query("lerg_7", ..., "switch={clli}") → switch details
68
+ \`\`\`
69
+
70
+ Or use \`lookup_tn\` for a quick consolidated view (dips LRN + CNAM + DNO + LERG in parallel).
71
+
72
+ ---
73
+
74
+ ## LERG Table Reference
75
+
76
+ ### Big 4 — Cover ~80% of Queries
77
+
78
+ **lerg_1** — OCN/carrier directory
79
+ - Fields: ocn_num, ocn_name, abbre_ocn_name, ocn_state, category, overall_ocn
80
+ - Use: Look up carrier name by OCN. Join from lerg_6 \`ocn\` → lerg_1 \`ocn_num\`.
81
+ - Example: \`lerg_query("lerg_1", "ocn_num,ocn_name,ocn_state", "ocn_num=567G")\`
82
+
83
+ **lerg_6** — NPA-NXX block assignments (the workhorse)
84
+ - Fields: npa, nxx, block_id, lata, lata_name, loc_state, ocn, aocn, switch, sha_indicator, rc_abbre, rc_type, coc_type, eff_date, status
85
+ - Has LATA + state + NPA + NXX + OCN + switch + rate center all on one row.
86
+ - BLOCK="A" = full NXX assignment; numeric 0-9 = thousands-block pooling.
87
+ - Example: \`lerg_query("lerg_6", "npa,nxx,loc_name,loc_state,ocn,switch,lata", "npa=720&nxx=708")\`
88
+
89
+ **lerg_7_sha** — Switch homing arrangements
90
+ - Fields: switch, sha_indicator, h_trm_d_tdm (FGD tandem), host, ocn
91
+ - Match \`switch\` + \`sha_indicator\` from lerg_6 to find the correct tandem.
92
+ - Or use \`lerg_tandem\` which does the join automatically.
93
+
94
+ **lerg_12** — LRN registry
95
+ - Fields: lrn, lata, lata_name, switch, ocn, status, eff_date
96
+ - Which company/switch established each LRN.
97
+
98
+ ### Supporting Tables
99
+
100
+ | Table | Purpose |
101
+ |-------|---------|
102
+ | lerg_3 | NPA (area code) metadata — state, effective date |
103
+ | lerg_5 | NPA/LATA cross-reference — which NPAs exist in a LATA |
104
+ | lerg_7 | Switch/CLLI details — address, coordinates, equipment type |
105
+ | lerg_8 | Rate center details — geography, V&H coordinates |
106
+ | lerg_8_loc | Localities (towns) → rate centers |
107
+ | lerg_8_pst | ZIP codes → localities (US only) |
108
+ | lerg_9 | Homing by tandem — "top-down" view of which NPA-NXXs subtend a tandem |
109
+ | lerg_4 | SS7 point codes |
110
+ | lerg_10 | NPA-NXX → operator services ATC |
111
+ | lerg_11 | Locality → operator services ATC |
112
+ | lerg_16 | IP capability by LRN |
113
+ | lerg_17 | IP capability by NPA-NXX |
114
+
115
+ Use \`lerg_table_info\` to list all tables or get the schema for a specific one.
116
+
117
+ ---
118
+
119
+ ## LERG Query Syntax
120
+
121
+ REST queries use path-based filters with \`&\` joining multiple conditions:
122
+ - Single filter: \`lerg_query("lerg_1", "ocn_num,ocn_name", "ocn_state=CO")\`
123
+ - Multiple filters: \`lerg_query("lerg_6", "npa,nxx,loc_name,ocn", "npa=303&nxx=629")\`
124
+
125
+ For complex queries with JOINs and advanced operators, use \`lerg_complex_query\`:
126
+ \`\`\`json
127
+ {
128
+ "table": "lerg_6",
129
+ "fields": ["npa", "nxx", "ocn", "loc_name"],
130
+ "filters": [{"field": "npa", "operator": "eq", "value": 720}],
131
+ "join": {
132
+ "table": "lerg_1",
133
+ "on": [{"left_field": "ocn", "right_field": "ocn_num"}],
134
+ "fields": ["ocn_name", "ocn_state"]
135
+ }
136
+ }
137
+ \`\`\`
138
+
139
+ Filter operators: eq, ne, gt, gte, lt, lte, like, in, isnull, isnotnull.
140
+
141
+ ---
142
+
143
+ ## CNAM (Caller Name)
144
+
145
+ \`cnam_lookup\` queries TransUnion's LIDB for the caller name associated with a phone number.
146
+
147
+ - Returns: calling_name (up to 15 chars), calling_name_status (available/unavailable), presentation_indicator (allowed/restricted)
148
+ - Results cached server-side for 24 hours
149
+ - "WIRELESS CALLER" typically means the carrier hasn't provisioned a specific CNAM entry
150
+
151
+ ---
152
+
153
+ ## DNO (Do Not Originate)
154
+
155
+ \`dno_check\` checks if a phone number should never appear as a caller ID.
156
+
157
+ - DNO numbers belong to entities that only receive calls (IRS, major banks, government agencies)
158
+ - If is_dno=true, the number appearing as caller ID indicates **spoofing/fraud**
159
+ - Supports prefix matching: 3-digit (NPA), 6-digit (NPA-NXX), 7-digit, or 10-digit patterns
160
+ - Response includes: is_dno, matched_pattern, source
161
+
162
+ ---
163
+
164
+ ## RouteLink — Toll-Free Number Routing
165
+
166
+ ### ROR (Responsible Organization)
167
+ \`routelink_lookup\` with lookup_type="ror" returns the RespOrg managing a toll-free number.
168
+ - RespOrg is a 5-char code (e.g., "NEX01", "TZN99")
169
+ - Only needs the CRN (toll-free number), no ANI/LATA required
170
+
171
+ ### CIC (Carrier Identification Code)
172
+ \`routelink_lookup\` with lookup_type="cic" or "cicror" returns which carrier handles calls to a toll-free number FROM a specific caller (ANI) in a specific LATA.
173
+ - Requires: crn, ani (10-digit), lata (3-digit)
174
+ - Common carrier codes: 0288 (AT&T), 0222 (MCI/Verizon), 0333 (Sprint), 0432 (Lumen)
175
+
176
+ ### CPR (Call Processing Record)
177
+ \`routelink_cpr\` retrieves the full routing decision tree for a toll-free number.
178
+
179
+ **Decision tree node types:**
180
+ | Node | Description |
181
+ |------|-------------|
182
+ | [LATA] | Routes by caller's LATA |
183
+ | [NPA] | Routes by caller's area code |
184
+ | [NXX] | Routes by caller's exchange |
185
+ | [STATE] | Routes by caller's state |
186
+ | [DAY_OF_WEEK] | Routes by day (1-7, Sunday=1) |
187
+ | [TIME_OF_DAY] | Routes by time (15-min intervals) |
188
+ | [PERCENT] | Percentage-based load balancing |
189
+ | [ANI] | Routes by specific caller number |
190
+
191
+ **Action types:** Carrier XXXX (4-digit carrier code), Template XXXXXXXXXX (reference to template CRN), Routing XXXXX, NMC X (Network Management Class)
192
+
193
+ **Common patterns:**
194
+ - Simple: All calls → one carrier → one termination number
195
+ - Time-of-day: Business hours → office, after hours → answering service
196
+ - Geographic: Different terminations per LATA/state/NPA
197
+ - Percentage: Load balancing across call centers (e.g., 60%/40%)
198
+
199
+ Use \`expand=true\` (default) to recursively resolve template references into their full decision trees.
200
+
201
+ ---
202
+
203
+ ## GraphQL
204
+
205
+ Use \`graphql_query\` for complex queries not possible with REST:
206
+ - Cross-table relationship joins (lerg6 → carrier, lerg6 → switchInfo, lerg7Sha → tandemSwitch)
207
+ - Filtering by fields not in REST endpoints
208
+ - Multiple related data points in one query
209
+
210
+ **LERG GraphQL** (\`service="lerg"\`): All 27 tables with camelCase names (lerg1, lerg6, lerg7Sha, etc.)
211
+ - FilterInput operators: EQ, NE, GT, GTE, LT, LTE, LIKE, IN, IS_NULL, IS_NOT_NULL
212
+ - All field values are nullable strings
213
+
214
+ **LSMS GraphQL** (\`service="lsms"\`): 5 tables
215
+ - subscriptionVersions (514M rows — MUST filter by phone_number, lrn, or spid)
216
+ - numberBlocks, serviceProviders, locationRoutingNumbers, npanxx
217
+ - Safety limits: max 1000 results, depth 5, complexity 200, 10-second timeout
218
+
219
+ ---
220
+
221
+ ## Key Telecom Concepts
222
+
223
+ | Term | Definition |
224
+ |------|-----------|
225
+ | **LRN** | Location Routing Number — identifies the switch serving a ported number |
226
+ | **SPID** | Service Provider ID — identifies the carrier that owns a number |
227
+ | **OCN** | Operating Company Number — 4-char carrier identifier (often same as SPID) |
228
+ | **NPA** | Numbering Plan Area — 3-digit area code |
229
+ | **NXX** | Exchange code — next 3 digits after area code |
230
+ | **LATA** | Local Access Transport Area — geographic region for call routing |
231
+ | **CLLI** | Common Language Location Identifier — 8-11 char switch/building code |
232
+ | **CRN** | Call Routing Number — a toll-free number in RouteLink context |
233
+ | **ROR/RespOrg** | Responsible Organization — entity managing a toll-free number's routing |
234
+ | **CIC** | Carrier Identification Code — identifies which carrier handles a toll-free call |
235
+ | **CPR** | Call Processing Record — routing decision tree for a toll-free number |
236
+ | **Rate Center** | Geographic area defining local calling boundaries |
237
+ | **Tandem** | A switching office that connects local switches to the long-distance network |
238
+ | **Homing** | The relationship between a local switch and its tandem |
239
+
240
+ ---
241
+
242
+ ## Common Mistakes to Avoid
243
+
244
+ 1. **Never guess carrier names** — always query lerg_1 by OCN
245
+ 2. **Never skip the LRN dip** — ported TNs have different NPA-NXX than their LRN
246
+ 3. **Never look for tandem/switch data in LSMS** — LSMS has no infrastructure data
247
+ 4. **Never look for TN-level data in LERG** — LERG has no per-phone-number data
248
+ 5. **Never query LSMS subscriptionVersions without a filter** — 514M rows will timeout
249
+ 6. **Always use the LRN's NPA-NXX** (not the TN's) for LERG routing lookups
250
+ `;
@@ -0,0 +1 @@
1
+ export declare const VERSION = "1.0.10";
@@ -0,0 +1 @@
1
+ export const VERSION = "1.0.10";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telique-mcp",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "MCP server for Telique telecom APIs (RouteLink, LRN, CNAM, LERG)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",