grantsignal-mcp 1.2.0 → 1.4.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/dist/agency-aliases.d.ts +44 -0
- package/dist/agency-aliases.d.ts.map +1 -0
- package/dist/agency-aliases.js +324 -0
- package/dist/agency-aliases.js.map +1 -0
- package/dist/ai-scoring.d.ts +35 -0
- package/dist/ai-scoring.d.ts.map +1 -0
- package/dist/ai-scoring.js +123 -0
- package/dist/ai-scoring.js.map +1 -0
- package/dist/config.d.ts +10 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +11 -5
- package/dist/config.js.map +1 -1
- package/dist/formatters.d.ts +59 -0
- package/dist/formatters.d.ts.map +1 -0
- package/dist/formatters.js +140 -0
- package/dist/formatters.js.map +1 -0
- package/dist/gap-detection.d.ts +67 -0
- package/dist/gap-detection.d.ts.map +1 -0
- package/dist/gap-detection.js +316 -0
- package/dist/gap-detection.js.map +1 -0
- package/dist/post-processing.d.ts +72 -0
- package/dist/post-processing.d.ts.map +1 -0
- package/dist/post-processing.js +211 -0
- package/dist/post-processing.js.map +1 -0
- package/dist/scoring.d.ts +171 -0
- package/dist/scoring.d.ts.map +1 -0
- package/dist/scoring.js +809 -0
- package/dist/scoring.js.map +1 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +2603 -930
- package/dist/server.js.map +1 -1
- package/dist/supabase-client.d.ts +28 -0
- package/dist/supabase-client.d.ts.map +1 -0
- package/dist/supabase-client.js +70 -0
- package/dist/supabase-client.js.map +1 -0
- package/dist/tier-config.d.ts +22 -0
- package/dist/tier-config.d.ts.map +1 -0
- package/dist/tier-config.js +86 -0
- package/dist/tier-config.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GrantSignal MCP Server — Agency Alias Resolution
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive alias map for NYC, NYS, and federal agency names.
|
|
5
|
+
* Resolves acronyms, misspellings, abbreviations, and informal names
|
|
6
|
+
* to canonical forms used across GrantSignal data sources.
|
|
7
|
+
*/
|
|
8
|
+
export interface AgencyInfo {
|
|
9
|
+
canonical: string;
|
|
10
|
+
fullName: string;
|
|
11
|
+
checkbookName?: string;
|
|
12
|
+
code?: string;
|
|
13
|
+
searchTerms: string[];
|
|
14
|
+
level: "nyc" | "nys" | "federal";
|
|
15
|
+
}
|
|
16
|
+
export declare const PROGRAM_ACRONYMS: Record<string, string>;
|
|
17
|
+
export interface ResolvedAgency {
|
|
18
|
+
canonical: string;
|
|
19
|
+
fullName: string;
|
|
20
|
+
checkbookName?: string;
|
|
21
|
+
code?: string;
|
|
22
|
+
searchTerms: string[];
|
|
23
|
+
level: "nyc" | "nys" | "federal";
|
|
24
|
+
resolved: boolean;
|
|
25
|
+
original: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve an agency input string to its canonical form.
|
|
29
|
+
*
|
|
30
|
+
* Checks exact match first, then tries substring matching against all
|
|
31
|
+
* search terms. Falls back to the original input if no match found.
|
|
32
|
+
*
|
|
33
|
+
* @returns ResolvedAgency with `resolved: true` if input was mapped to canonical
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveAgency(input: string): ResolvedAgency;
|
|
36
|
+
/**
|
|
37
|
+
* Get the best filter value to pass to a Supabase RPC.
|
|
38
|
+
*
|
|
39
|
+
* @param prefer - 'checkbook' returns the exact Checkbook agency_name (best for spending/budget RPCs)
|
|
40
|
+
* 'code' returns the 3-digit agency code
|
|
41
|
+
* 'canonical' (default) returns the acronym
|
|
42
|
+
*/
|
|
43
|
+
export declare function getAgencyFilterValue(resolved: ResolvedAgency, prefer?: 'checkbook' | 'code' | 'canonical' | boolean): string;
|
|
44
|
+
//# sourceMappingURL=agency-aliases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agency-aliases.d.ts","sourceRoot":"","sources":["../src/agency-aliases.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC;CAClC;AA+MD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAoBnD,CAAC;AA2BF,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CA+C3D;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,cAAc,EACxB,MAAM,GAAE,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,OAAqB,GACjE,MAAM,CAcR"}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GrantSignal MCP Server — Agency Alias Resolution
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive alias map for NYC, NYS, and federal agency names.
|
|
5
|
+
* Resolves acronyms, misspellings, abbreviations, and informal names
|
|
6
|
+
* to canonical forms used across GrantSignal data sources.
|
|
7
|
+
*/
|
|
8
|
+
// ── NYC Agencies (~25) ──────────────────────────────────────
|
|
9
|
+
const NYC_AGENCIES = [
|
|
10
|
+
{
|
|
11
|
+
canonical: "DFTA", fullName: "Department for the Aging", code: "125", level: "nyc",
|
|
12
|
+
searchTerms: ["dfta", "deta", "aging", "dept for the aging", "department for the aging", "senior services", "seniors", "older adults"],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
canonical: "DYCD", fullName: "Department of Youth and Community Development", code: "260", level: "nyc",
|
|
16
|
+
searchTerms: ["dycd", "youth", "community development", "dept of youth", "department of youth and community development", "after school", "afterschool", "compass", "beacon"],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
canonical: "DOHMH", fullName: "Department of Health and Mental Hygiene", code: "816", level: "nyc",
|
|
20
|
+
searchTerms: ["dohmh", "health", "mental hygiene", "dept of health", "department of health", "public health", "mental health"],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
canonical: "ACS", fullName: "Administration for Children's Services", code: "068", level: "nyc",
|
|
24
|
+
searchTerms: ["acs", "children's services", "child welfare", "child services", "administration for children", "foster care", "child protective"],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
canonical: "DHS", fullName: "Department of Homeless Services", code: "069", level: "nyc",
|
|
28
|
+
searchTerms: ["dhs", "homeless services", "dept of homeless", "department of homeless services", "shelter", "homelessness"],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
canonical: "HRA", fullName: "Human Resources Administration", code: "071", level: "nyc",
|
|
32
|
+
searchTerms: ["hra", "dss", "human resources administration", "dept of social services", "department of social services", "social services", "welfare", "public assistance", "snap", "food stamps", "cash assistance"],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
canonical: "DOE", fullName: "Department of Education (NYC)", checkbookName: "Department of Education", code: "040", level: "nyc",
|
|
36
|
+
searchTerms: ["doe", "doe nyc", "nyc doe", "nyc education", "nyc dept of education", "nyc department of education", "department of education", "dept of education", "public schools nyc", "board of education nyc"],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
canonical: "NYPD", fullName: "New York City Police Department", checkbookName: "Police Department", code: "056", level: "nyc",
|
|
40
|
+
searchTerms: ["nypd", "police", "nyc police", "new york city police", "law enforcement nyc", "police department"],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
canonical: "FDNY", fullName: "Fire Department of the City of New York", checkbookName: "Fire Department", code: "057", level: "nyc",
|
|
44
|
+
searchTerms: ["fdny", "fire department", "fire dept", "nyc fire"],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
canonical: "HPD", fullName: "Department of Housing Preservation and Development", code: "806", level: "nyc",
|
|
48
|
+
searchTerms: ["hpd", "housing preservation", "housing development", "dept of housing", "department of housing", "affordable housing nyc", "housing nyc"],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
canonical: "DOT", fullName: "Department of Transportation (NYC)", code: "841", level: "nyc",
|
|
52
|
+
searchTerms: ["dot nyc", "nyc dot", "nyc transportation", "dept of transportation nyc", "streets", "traffic nyc"],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
canonical: "DPR", fullName: "Department of Parks and Recreation", code: "846", level: "nyc",
|
|
56
|
+
searchTerms: ["dpr", "parks", "parks and recreation", "dept of parks", "department of parks", "nyc parks", "recreation"],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
canonical: "DCLA", fullName: "Department of Cultural Affairs", code: "126", level: "nyc",
|
|
60
|
+
searchTerms: ["dcla", "cultural affairs", "dept of cultural affairs", "department of cultural affairs", "arts", "culture", "cultural funding"],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
canonical: "SBS", fullName: "Department of Small Business Services", code: "801", level: "nyc",
|
|
64
|
+
searchTerms: ["sbs", "small business", "small business services", "dept of small business", "department of small business services", "mwbe", "workforce1"],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
canonical: "DEP", fullName: "Department of Environmental Protection", code: "826", level: "nyc",
|
|
68
|
+
searchTerms: ["dep", "environmental protection", "dept of environmental protection", "water", "sewer", "environment nyc"],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
canonical: "DSNY", fullName: "Department of Sanitation", code: "827", level: "nyc",
|
|
72
|
+
searchTerms: ["dsny", "sanitation", "dept of sanitation", "department of sanitation", "garbage", "recycling", "waste", "cleanup"],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
canonical: "DOB", fullName: "Department of Buildings", code: "810", level: "nyc",
|
|
76
|
+
searchTerms: ["dob", "buildings", "dept of buildings", "department of buildings", "building permits", "construction permits"],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
canonical: "MOCJ", fullName: "Mayor's Office of Criminal Justice", code: "098", level: "nyc",
|
|
80
|
+
searchTerms: ["mocj", "criminal justice", "mayor's office of criminal justice", "public safety"],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
canonical: "NYCHA", fullName: "New York City Housing Authority", level: "nyc",
|
|
84
|
+
searchTerms: ["nycha", "housing authority", "public housing", "section 8 nyc"],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
canonical: "H+H", fullName: "NYC Health + Hospitals", level: "nyc",
|
|
88
|
+
searchTerms: ["h+h", "hhc", "health and hospitals", "health + hospitals", "nyc health hospitals", "public hospitals", "bellevue", "elmhurst hospital", "kings county hospital"],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
canonical: "NYCEDC", fullName: "NYC Economic Development Corporation", level: "nyc",
|
|
92
|
+
searchTerms: ["nycedc", "edc", "economic development", "economic development corporation"],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
canonical: "MOIA", fullName: "Mayor's Office of Immigrant Affairs", level: "nyc",
|
|
96
|
+
searchTerms: ["moia", "immigrant affairs", "immigration", "immigrant services"],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
canonical: "MOPD", fullName: "Mayor's Office for People with Disabilities", level: "nyc",
|
|
100
|
+
searchTerms: ["mopd", "disabilities", "people with disabilities", "disability services"],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
canonical: "DVS", fullName: "Department of Veterans' Services", level: "nyc",
|
|
104
|
+
searchTerms: ["dvs", "veterans", "veteran services", "dept of veterans"],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
canonical: "OATH", fullName: "Office of Administrative Trials and Hearings", level: "nyc",
|
|
108
|
+
searchTerms: ["oath", "administrative trials", "hearings"],
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
// ── NYS Agencies (~10) ──────────────────────────────────────
|
|
112
|
+
const NYS_AGENCIES = [
|
|
113
|
+
{
|
|
114
|
+
canonical: "NYSED", fullName: "New York State Education Department", level: "nys",
|
|
115
|
+
searchTerms: ["nysed", "nys education", "state education", "education department nys", "board of regents"],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
canonical: "NYSDOH", fullName: "New York State Department of Health", level: "nys",
|
|
119
|
+
searchTerms: ["nysdoh", "nys health", "state health", "nys dept of health", "nys department of health"],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
canonical: "OTDA", fullName: "Office of Temporary and Disability Assistance", level: "nys",
|
|
123
|
+
searchTerms: ["otda", "temporary assistance", "disability assistance", "nys welfare", "tanf nys"],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
canonical: "OCFS", fullName: "Office of Children and Family Services", level: "nys",
|
|
127
|
+
searchTerms: ["ocfs", "children and family", "nys children", "nys family services", "child care nys"],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
canonical: "OMH", fullName: "Office of Mental Health", level: "nys",
|
|
131
|
+
searchTerms: ["omh", "nys mental health", "state mental health", "office of mental health"],
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
canonical: "OASAS", fullName: "Office of Addiction Services and Supports", level: "nys",
|
|
135
|
+
searchTerms: ["oasas", "addiction services", "substance abuse nys", "nys addiction", "drug treatment nys"],
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
canonical: "NYSERDA", fullName: "New York State Energy Research and Development Authority", level: "nys",
|
|
139
|
+
searchTerms: ["nyserda", "energy research", "nys energy", "clean energy nys", "energy efficiency nys"],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
canonical: "ESD", fullName: "Empire State Development", level: "nys",
|
|
143
|
+
searchTerms: ["esd", "empire state development", "nys economic development", "excelsior", "nys incentives"],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
canonical: "DOS", fullName: "Department of State (NYS)", level: "nys",
|
|
147
|
+
searchTerms: ["nys dos", "department of state nys", "nys dept of state", "nys charities"],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
canonical: "DEC", fullName: "Department of Environmental Conservation", level: "nys",
|
|
151
|
+
searchTerms: ["dec", "nys dec", "environmental conservation", "nys environment", "nys dept of environmental conservation"],
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
// ── Federal Agencies (~12) ──────────────────────────────────
|
|
155
|
+
const FEDERAL_AGENCIES = [
|
|
156
|
+
{
|
|
157
|
+
canonical: "HHS", fullName: "Department of Health and Human Services", level: "federal",
|
|
158
|
+
searchTerms: ["hhs", "health and human services", "dept of health and human services", "department of health and human services"],
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
canonical: "DOE-FED", fullName: "Department of Education (Federal)", level: "federal",
|
|
162
|
+
searchTerms: ["doe federal", "federal doe", "us doe", "federal education", "ed.gov", "us department of education"],
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
canonical: "EPA", fullName: "Environmental Protection Agency", level: "federal",
|
|
166
|
+
searchTerms: ["epa", "environmental protection agency", "environment federal"],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
canonical: "USDA", fullName: "U.S. Department of Agriculture", level: "federal",
|
|
170
|
+
searchTerms: ["usda", "agriculture", "dept of agriculture", "department of agriculture", "farm bill", "rural development"],
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
canonical: "NIH", fullName: "National Institutes of Health", level: "federal",
|
|
174
|
+
searchTerms: ["nih", "national institutes of health", "biomedical research", "medical research federal"],
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
canonical: "NSF", fullName: "National Science Foundation", level: "federal",
|
|
178
|
+
searchTerms: ["nsf", "national science foundation", "science funding", "research funding federal"],
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
canonical: "DOJ", fullName: "Department of Justice", level: "federal",
|
|
182
|
+
searchTerms: ["doj", "dept of justice", "department of justice", "justice department", "federal law enforcement", "ojp", "bja"],
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
canonical: "DOL", fullName: "Department of Labor", level: "federal",
|
|
186
|
+
searchTerms: ["dol", "dept of labor", "department of labor", "labor department", "workforce", "wioa", "employment federal"],
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
canonical: "HUD", fullName: "Department of Housing and Urban Development", level: "federal",
|
|
190
|
+
searchTerms: ["hud", "housing and urban development", "dept of housing", "department of housing and urban development", "cdbg", "section 8", "affordable housing federal"],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
canonical: "DOT", fullName: "Department of Transportation (Federal)", level: "federal",
|
|
194
|
+
searchTerms: ["dot federal", "federal dot", "dept of transportation", "department of transportation", "fhwa", "fta", "federal transit"],
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
canonical: "FEMA", fullName: "Federal Emergency Management Agency", level: "federal",
|
|
198
|
+
searchTerms: ["fema", "emergency management", "disaster relief", "federal emergency"],
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
canonical: "SBA", fullName: "Small Business Administration", level: "federal",
|
|
202
|
+
searchTerms: ["sba", "small business administration", "small business federal"],
|
|
203
|
+
},
|
|
204
|
+
];
|
|
205
|
+
// ── Common Program Acronyms (reference, not agencies) ───────
|
|
206
|
+
export const PROGRAM_ACRONYMS = {
|
|
207
|
+
NORC: "Naturally Occurring Retirement Community",
|
|
208
|
+
NDA: "Neighborhood Development Area",
|
|
209
|
+
COMPASS: "Comprehensive After School System of NYC",
|
|
210
|
+
SYEP: "Summer Youth Employment Program",
|
|
211
|
+
SNAP: "Supplemental Nutrition Assistance Program",
|
|
212
|
+
LIHTC: "Low-Income Housing Tax Credit",
|
|
213
|
+
CDBG: "Community Development Block Grant",
|
|
214
|
+
MWBE: "Minority and Women-owned Business Enterprise",
|
|
215
|
+
"M/WBE": "Minority and Women-owned Business Enterprise",
|
|
216
|
+
SCRIE: "Senior Citizen Rent Increase Exemption",
|
|
217
|
+
DRIE: "Disability Rent Increase Exemption",
|
|
218
|
+
ELL: "English Language Learner",
|
|
219
|
+
ARPA: "American Rescue Plan Act",
|
|
220
|
+
WIOA: "Workforce Innovation and Opportunity Act",
|
|
221
|
+
TANF: "Temporary Assistance for Needy Families",
|
|
222
|
+
SSVF: "Supportive Services for Veteran Families",
|
|
223
|
+
VASH: "Veterans Affairs Supportive Housing",
|
|
224
|
+
"CASA": "Court Appointed Special Advocates",
|
|
225
|
+
DoVE: "Domestic Violence Empowerment",
|
|
226
|
+
};
|
|
227
|
+
// ── Merged Agency List ──────────────────────────────────────
|
|
228
|
+
const ALL_AGENCIES = [
|
|
229
|
+
...NYC_AGENCIES,
|
|
230
|
+
...NYS_AGENCIES,
|
|
231
|
+
...FEDERAL_AGENCIES,
|
|
232
|
+
];
|
|
233
|
+
// Build lookup index: lowercase search term → AgencyInfo
|
|
234
|
+
const ALIAS_INDEX = new Map();
|
|
235
|
+
for (const agency of ALL_AGENCIES) {
|
|
236
|
+
// Index by canonical (lowercase)
|
|
237
|
+
ALIAS_INDEX.set(agency.canonical.toLowerCase(), agency);
|
|
238
|
+
// Index by all search terms
|
|
239
|
+
for (const term of agency.searchTerms) {
|
|
240
|
+
ALIAS_INDEX.set(term.toLowerCase(), agency);
|
|
241
|
+
}
|
|
242
|
+
// Index by code if present
|
|
243
|
+
if (agency.code) {
|
|
244
|
+
ALIAS_INDEX.set(agency.code, agency);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Resolve an agency input string to its canonical form.
|
|
249
|
+
*
|
|
250
|
+
* Checks exact match first, then tries substring matching against all
|
|
251
|
+
* search terms. Falls back to the original input if no match found.
|
|
252
|
+
*
|
|
253
|
+
* @returns ResolvedAgency with `resolved: true` if input was mapped to canonical
|
|
254
|
+
*/
|
|
255
|
+
export function resolveAgency(input) {
|
|
256
|
+
const trimmed = input.trim();
|
|
257
|
+
const lower = trimmed.toLowerCase();
|
|
258
|
+
// 1. Exact match against index
|
|
259
|
+
const exact = ALIAS_INDEX.get(lower);
|
|
260
|
+
if (exact) {
|
|
261
|
+
return {
|
|
262
|
+
...exact,
|
|
263
|
+
resolved: exact.canonical.toLowerCase() !== lower,
|
|
264
|
+
original: trimmed,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
// 2. Check if input is a numeric agency code
|
|
268
|
+
if (/^\d{2,3}$/.test(trimmed)) {
|
|
269
|
+
const byCode = ALIAS_INDEX.get(trimmed);
|
|
270
|
+
if (byCode) {
|
|
271
|
+
return { ...byCode, resolved: true, original: trimmed };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
// 3. Substring match: find agencies where any search term contains the input
|
|
275
|
+
// or the input contains any search term (for longer inputs like full names)
|
|
276
|
+
const candidates = [];
|
|
277
|
+
for (const agency of ALL_AGENCIES) {
|
|
278
|
+
for (const term of agency.searchTerms) {
|
|
279
|
+
if (term.includes(lower) || lower.includes(term)) {
|
|
280
|
+
candidates.push(agency);
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (candidates.length === 1) {
|
|
286
|
+
return { ...candidates[0], resolved: true, original: trimmed };
|
|
287
|
+
}
|
|
288
|
+
// 4. No match — return unresolved (pass through to ILIKE)
|
|
289
|
+
return {
|
|
290
|
+
canonical: trimmed,
|
|
291
|
+
fullName: trimmed,
|
|
292
|
+
searchTerms: [lower],
|
|
293
|
+
level: "nyc", // default, doesn't matter for unresolved
|
|
294
|
+
resolved: false,
|
|
295
|
+
original: trimmed,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Get the best filter value to pass to a Supabase RPC.
|
|
300
|
+
*
|
|
301
|
+
* @param prefer - 'checkbook' returns the exact Checkbook agency_name (best for spending/budget RPCs)
|
|
302
|
+
* 'code' returns the 3-digit agency code
|
|
303
|
+
* 'canonical' (default) returns the acronym
|
|
304
|
+
*/
|
|
305
|
+
export function getAgencyFilterValue(resolved, prefer = 'canonical') {
|
|
306
|
+
// Backward compat: true = 'code', false = 'canonical'
|
|
307
|
+
if (prefer === true)
|
|
308
|
+
prefer = 'code';
|
|
309
|
+
if (prefer === false)
|
|
310
|
+
prefer = 'canonical';
|
|
311
|
+
if (prefer === 'checkbook') {
|
|
312
|
+
// Return exact Checkbook name for best matching in spending/budget RPCs
|
|
313
|
+
if (resolved.checkbookName)
|
|
314
|
+
return resolved.checkbookName;
|
|
315
|
+
// Fall back to fullName (works for most agencies where fullName matches Checkbook)
|
|
316
|
+
if (resolved.resolved && resolved.fullName)
|
|
317
|
+
return resolved.fullName;
|
|
318
|
+
return resolved.original;
|
|
319
|
+
}
|
|
320
|
+
if (prefer === 'code' && resolved.code)
|
|
321
|
+
return resolved.code;
|
|
322
|
+
return resolved.resolved ? resolved.canonical : resolved.original;
|
|
323
|
+
}
|
|
324
|
+
//# sourceMappingURL=agency-aliases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agency-aliases.js","sourceRoot":"","sources":["../src/agency-aliases.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,+DAA+D;AAE/D,MAAM,YAAY,GAAiB;IACjC;QACE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,0BAA0B,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;QAClF,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,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AAO,QAAQ,CAAC,QAAQ,CAAC;QACrE,OAAO,QAAQ,CAAC,QAAQ,CAAC;IAC3B,CAAC;IACD,IAAI,MAAM,KAAK,MAAM,IAAI,QAAQ,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC;IAC7D,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GrantSignal MCP Server — AI Scoring (Claude Haiku)
|
|
3
|
+
*
|
|
4
|
+
* Lightweight wrapper around the Anthropic API for AI-powered tools.
|
|
5
|
+
* Ported from convex/lib/aiScoring.ts.
|
|
6
|
+
*/
|
|
7
|
+
export interface AiScoringResult {
|
|
8
|
+
text: string;
|
|
9
|
+
tokenCount: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Call Claude Haiku with a system prompt and user message.
|
|
13
|
+
* Returns null on failure (never throws).
|
|
14
|
+
*
|
|
15
|
+
* @param apiKey - Anthropic API key (passed explicitly for Worker compatibility)
|
|
16
|
+
*/
|
|
17
|
+
export declare function callHaiku(apiKey: string, systemPrompt: string, userMessage: string, maxTokens?: number): Promise<AiScoringResult | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Build a smart-match prompt for scoring grant candidates.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildSmartMatchPrompt(orgProfile: {
|
|
22
|
+
orgName?: string;
|
|
23
|
+
orgType?: string;
|
|
24
|
+
mission?: string;
|
|
25
|
+
focusAreas?: string[];
|
|
26
|
+
populationsServed?: string[];
|
|
27
|
+
city?: string;
|
|
28
|
+
state?: string;
|
|
29
|
+
budgetSize?: number;
|
|
30
|
+
certifications?: string[];
|
|
31
|
+
}): string;
|
|
32
|
+
export declare const SMART_MATCH_SYSTEM_PROMPT = "You are a grant matching expert. Given an organization profile and a list of grant opportunities, score each grant on how well it matches the organization.\n\nFor each grant, provide:\n1. A match score from 0-100\n2. A 1-2 sentence rationale\n\nReturn ONLY valid JSON in this format:\n{\n \"scores\": [\n { \"id\": \"GRANT-0\", \"score\": 85, \"rationale\": \"Strong match because...\" },\n { \"id\": \"GRANT-1\", \"score\": 42, \"rationale\": \"Weak match because...\" },\n ...\n ]\n}\n\nUse the exact GRANT-N identifier shown in brackets before each grant.\n\nScoring guidelines:\n- 90-100: Near-perfect match \u2014 org's mission, populations, and capacity directly align\n- 70-89: Strong match \u2014 most criteria align, minor gaps\n- 50-69: Moderate match \u2014 some alignment but significant gaps in focus or capacity\n- 30-49: Weak match \u2014 tangential relevance only\n- 0-29: Poor match \u2014 wrong sector, geography, or capacity\n\nConsider: mission alignment, geographic eligibility, organizational type eligibility, budget/capacity match, population served overlap, focus area relevance.\n\nBe critical and realistic. Most grants should NOT score above 80 unless there's a very clear match.";
|
|
33
|
+
export declare const OPPORTUNITY_ANALYSIS_SYSTEM_PROMPT = "You are a grant strategy expert with deep knowledge of government funding. Analyze the provided grant opportunity using the competitive intelligence data.\n\nProduce a strategic briefing with these sections:\n\n1. **Overview** \u2014 2-3 sentence summary of the opportunity, who it's for, and what it funds.\n2. **Who Wins These Grants** \u2014 Based on award history data, describe the typical winning organization (size, type, track record). Name specific past winners if available.\n3. **Competitive Landscape** \u2014 How competitive is this? Estimate the number of applicants and success rate based on award data and typical demand for this type of funding.\n4. **Key Requirements** \u2014 The most critical eligibility and application requirements. What disqualifies applicants?\n5. **Strategic Recommendations** \u2014 3-5 actionable tips for a strong application. What differentiates winners from losers?\n6. **Red Flags & Risks** \u2014 Anything to watch out for: tight timelines, matching requirements, complex reporting, political considerations.\n\nKeep it concise and actionable. Use bullet points. Avoid generic advice \u2014 be specific to THIS grant.\n\nReturn plain text (markdown formatting is fine). Do NOT return JSON.";
|
|
34
|
+
export declare const ORG_INTELLIGENCE_SYSTEM_PROMPT = "You are a nonprofit funding strategist analyzing an organization's complete data profile. Synthesize all available data into an actionable intelligence brief.\n\nProduce a strategic briefing with these sections:\n\n1. **Organization Snapshot** \u2014 Type, location, size, and primary mission based on available data.\n2. **Revenue & Financial Health** \u2014 Revenue trends, diversity of funding sources, government dependency ratio, assets, growth trajectory. Flag any concerns (declining revenue, high dependency on single source).\n3. **Government Funding Profile** \u2014 Total government funding received, key agencies, types of awards. What's their government funding niche?\n4. **Compliance & Risk Assessment** \u2014 Audit results, M/WBE status, lobbying activity. Any red flags or concerns for potential funders?\n5. **Competitive Positioning** \u2014 What makes this org stand out? What are their strengths vs. peers?\n6. **Strategic Recommendations** \u2014 3-5 specific, actionable recommendations: new funding sources to pursue, capabilities to develop, relationships to build, risks to mitigate.\n7. **Funding Gaps** \u2014 Based on their mission and current funding, what types of grants should they pursue that they're currently missing?\n\nBe analytical and specific. Reference actual numbers from the data. Avoid generic advice \u2014 make recommendations based on THIS organization's specific profile.\n\nReturn plain text (markdown formatting is fine). Do NOT return JSON.";
|
|
35
|
+
//# sourceMappingURL=ai-scoring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-scoring.d.ts","sourceRoot":"","sources":["../src/ai-scoring.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,SAAS,SAAO,GACf,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAqCjC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,GAAG,MAAM,CAYT;AAED,eAAO,MAAM,yBAAyB,usCA0B8D,CAAC;AAErG,eAAO,MAAM,kCAAkC,2tCAasB,CAAC;AAEtE,eAAO,MAAM,8BAA8B,09CAc0B,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GrantSignal MCP Server — AI Scoring (Claude Haiku)
|
|
3
|
+
*
|
|
4
|
+
* Lightweight wrapper around the Anthropic API for AI-powered tools.
|
|
5
|
+
* Ported from convex/lib/aiScoring.ts.
|
|
6
|
+
*/
|
|
7
|
+
const HAIKU_MODEL = "claude-haiku-4-5-20251001";
|
|
8
|
+
const API_URL = "https://api.anthropic.com/v1/messages";
|
|
9
|
+
/**
|
|
10
|
+
* Call Claude Haiku with a system prompt and user message.
|
|
11
|
+
* Returns null on failure (never throws).
|
|
12
|
+
*
|
|
13
|
+
* @param apiKey - Anthropic API key (passed explicitly for Worker compatibility)
|
|
14
|
+
*/
|
|
15
|
+
export async function callHaiku(apiKey, systemPrompt, userMessage, maxTokens = 1500) {
|
|
16
|
+
if (!apiKey) {
|
|
17
|
+
console.warn("[aiScoring] No API key — skipping AI scoring");
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const resp = await fetch(API_URL, {
|
|
22
|
+
method: "POST",
|
|
23
|
+
headers: {
|
|
24
|
+
"Content-Type": "application/json",
|
|
25
|
+
"x-api-key": apiKey,
|
|
26
|
+
"anthropic-version": "2023-06-01",
|
|
27
|
+
},
|
|
28
|
+
body: JSON.stringify({
|
|
29
|
+
model: HAIKU_MODEL,
|
|
30
|
+
max_tokens: maxTokens,
|
|
31
|
+
system: systemPrompt,
|
|
32
|
+
messages: [{ role: "user", content: userMessage }],
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
if (!resp.ok) {
|
|
36
|
+
const err = await resp.text();
|
|
37
|
+
console.error(`[aiScoring] Haiku API error ${resp.status}: ${err.substring(0, 200)}`);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const data = await resp.json();
|
|
41
|
+
return {
|
|
42
|
+
text: data.content?.[0]?.text ?? "",
|
|
43
|
+
tokenCount: (data.usage?.input_tokens ?? 0) + (data.usage?.output_tokens ?? 0),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
console.error(`[aiScoring] Haiku call failed: ${err.message}`);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build a smart-match prompt for scoring grant candidates.
|
|
53
|
+
*/
|
|
54
|
+
export function buildSmartMatchPrompt(orgProfile) {
|
|
55
|
+
const parts = [
|
|
56
|
+
`Organization: ${orgProfile.orgName || "Unknown"}`,
|
|
57
|
+
orgProfile.orgType ? `Type: ${orgProfile.orgType}` : null,
|
|
58
|
+
orgProfile.mission ? `Mission: ${orgProfile.mission}` : null,
|
|
59
|
+
orgProfile.focusAreas?.length ? `Focus Areas: ${orgProfile.focusAreas.join(", ")}` : null,
|
|
60
|
+
orgProfile.populationsServed?.length ? `Populations Served: ${orgProfile.populationsServed.join(", ")}` : null,
|
|
61
|
+
orgProfile.city || orgProfile.state ? `Location: ${[orgProfile.city, orgProfile.state].filter(Boolean).join(", ")}` : null,
|
|
62
|
+
orgProfile.budgetSize ? `Annual Budget: $${orgProfile.budgetSize.toLocaleString()}` : null,
|
|
63
|
+
orgProfile.certifications?.length ? `Certifications: ${orgProfile.certifications.join(", ")}` : null,
|
|
64
|
+
];
|
|
65
|
+
return parts.filter(Boolean).join("\n");
|
|
66
|
+
}
|
|
67
|
+
export const SMART_MATCH_SYSTEM_PROMPT = `You are a grant matching expert. Given an organization profile and a list of grant opportunities, score each grant on how well it matches the organization.
|
|
68
|
+
|
|
69
|
+
For each grant, provide:
|
|
70
|
+
1. A match score from 0-100
|
|
71
|
+
2. A 1-2 sentence rationale
|
|
72
|
+
|
|
73
|
+
Return ONLY valid JSON in this format:
|
|
74
|
+
{
|
|
75
|
+
"scores": [
|
|
76
|
+
{ "id": "GRANT-0", "score": 85, "rationale": "Strong match because..." },
|
|
77
|
+
{ "id": "GRANT-1", "score": 42, "rationale": "Weak match because..." },
|
|
78
|
+
...
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
Use the exact GRANT-N identifier shown in brackets before each grant.
|
|
83
|
+
|
|
84
|
+
Scoring guidelines:
|
|
85
|
+
- 90-100: Near-perfect match — org's mission, populations, and capacity directly align
|
|
86
|
+
- 70-89: Strong match — most criteria align, minor gaps
|
|
87
|
+
- 50-69: Moderate match — some alignment but significant gaps in focus or capacity
|
|
88
|
+
- 30-49: Weak match — tangential relevance only
|
|
89
|
+
- 0-29: Poor match — wrong sector, geography, or capacity
|
|
90
|
+
|
|
91
|
+
Consider: mission alignment, geographic eligibility, organizational type eligibility, budget/capacity match, population served overlap, focus area relevance.
|
|
92
|
+
|
|
93
|
+
Be critical and realistic. Most grants should NOT score above 80 unless there's a very clear match.`;
|
|
94
|
+
export const OPPORTUNITY_ANALYSIS_SYSTEM_PROMPT = `You are a grant strategy expert with deep knowledge of government funding. Analyze the provided grant opportunity using the competitive intelligence data.
|
|
95
|
+
|
|
96
|
+
Produce a strategic briefing with these sections:
|
|
97
|
+
|
|
98
|
+
1. **Overview** — 2-3 sentence summary of the opportunity, who it's for, and what it funds.
|
|
99
|
+
2. **Who Wins These Grants** — Based on award history data, describe the typical winning organization (size, type, track record). Name specific past winners if available.
|
|
100
|
+
3. **Competitive Landscape** — How competitive is this? Estimate the number of applicants and success rate based on award data and typical demand for this type of funding.
|
|
101
|
+
4. **Key Requirements** — The most critical eligibility and application requirements. What disqualifies applicants?
|
|
102
|
+
5. **Strategic Recommendations** — 3-5 actionable tips for a strong application. What differentiates winners from losers?
|
|
103
|
+
6. **Red Flags & Risks** — Anything to watch out for: tight timelines, matching requirements, complex reporting, political considerations.
|
|
104
|
+
|
|
105
|
+
Keep it concise and actionable. Use bullet points. Avoid generic advice — be specific to THIS grant.
|
|
106
|
+
|
|
107
|
+
Return plain text (markdown formatting is fine). Do NOT return JSON.`;
|
|
108
|
+
export const ORG_INTELLIGENCE_SYSTEM_PROMPT = `You are a nonprofit funding strategist analyzing an organization's complete data profile. Synthesize all available data into an actionable intelligence brief.
|
|
109
|
+
|
|
110
|
+
Produce a strategic briefing with these sections:
|
|
111
|
+
|
|
112
|
+
1. **Organization Snapshot** — Type, location, size, and primary mission based on available data.
|
|
113
|
+
2. **Revenue & Financial Health** — Revenue trends, diversity of funding sources, government dependency ratio, assets, growth trajectory. Flag any concerns (declining revenue, high dependency on single source).
|
|
114
|
+
3. **Government Funding Profile** — Total government funding received, key agencies, types of awards. What's their government funding niche?
|
|
115
|
+
4. **Compliance & Risk Assessment** — Audit results, M/WBE status, lobbying activity. Any red flags or concerns for potential funders?
|
|
116
|
+
5. **Competitive Positioning** — What makes this org stand out? What are their strengths vs. peers?
|
|
117
|
+
6. **Strategic Recommendations** — 3-5 specific, actionable recommendations: new funding sources to pursue, capabilities to develop, relationships to build, risks to mitigate.
|
|
118
|
+
7. **Funding Gaps** — Based on their mission and current funding, what types of grants should they pursue that they're currently missing?
|
|
119
|
+
|
|
120
|
+
Be analytical and specific. Reference actual numbers from the data. Avoid generic advice — make recommendations based on THIS organization's specific profile.
|
|
121
|
+
|
|
122
|
+
Return plain text (markdown formatting is fine). Do NOT return JSON.`;
|
|
123
|
+
//# sourceMappingURL=ai-scoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-scoring.js","sourceRoot":"","sources":["../src/ai-scoring.ts"],"names":[],"mappings":"AAAA;;;;;G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CAAC,CAAC,CAAC,mBAAmB,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;KACrG,CAAC;IACF,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;oGA0B2D,CAAC;AAErG,MAAM,CAAC,MAAM,kCAAkC,GAAG;;;;;;;;;;;;;qEAamB,CAAC;AAEtE,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;qEAcuB,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* GrantSignal MCP Server — Configuration
|
|
3
3
|
*
|
|
4
|
-
* Reads
|
|
5
|
-
* Falls back to the production Convex deployment.
|
|
4
|
+
* Reads Supabase credentials and optional API keys from environment variables.
|
|
6
5
|
*/
|
|
7
6
|
export declare const config: {
|
|
8
|
-
/**
|
|
7
|
+
/** Supabase project URL */
|
|
8
|
+
supabaseUrl: string;
|
|
9
|
+
/** Supabase service role key (full DB access) */
|
|
10
|
+
supabaseKey: string;
|
|
11
|
+
/** Anthropic API key for AI-powered tools */
|
|
12
|
+
anthropicApiKey: string;
|
|
13
|
+
/** Legacy: Convex API URL (kept for client.ts backward compat) */
|
|
9
14
|
apiUrl: string;
|
|
10
|
-
/**
|
|
11
|
-
apiKey: string
|
|
15
|
+
/** Legacy: API key for Convex (kept for client.ts backward compat) */
|
|
16
|
+
apiKey: string;
|
|
12
17
|
};
|
|
13
18
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,MAAM;IACjB,2BAA2B;;IAK3B,iDAAiD;;IAGjD,6CAA6C;;IAI7C,kEAAkE;;IAKlE,sEAAsE;;CAEvE,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* GrantSignal MCP Server — Configuration
|
|
3
3
|
*
|
|
4
|
-
* Reads
|
|
5
|
-
* Falls back to the production Convex deployment.
|
|
4
|
+
* Reads Supabase credentials and optional API keys from environment variables.
|
|
6
5
|
*/
|
|
7
6
|
export const config = {
|
|
8
|
-
/**
|
|
7
|
+
/** Supabase project URL */
|
|
8
|
+
supabaseUrl: process.env.SUPABASE_URL ||
|
|
9
|
+
"https://ykbpdjxhxlzkmpezjvhx.supabase.co",
|
|
10
|
+
/** Supabase service role key (full DB access) */
|
|
11
|
+
supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY || "",
|
|
12
|
+
/** Anthropic API key for AI-powered tools */
|
|
13
|
+
anthropicApiKey: process.env.ANTHROPIC_API_KEY || process.env.CLAUDE_API_KEY || "",
|
|
14
|
+
/** Legacy: Convex API URL (kept for client.ts backward compat) */
|
|
9
15
|
apiUrl: process.env.GRANTSIGNAL_API_URL ||
|
|
10
16
|
"https://wooden-coyote-415.convex.site",
|
|
11
|
-
/**
|
|
12
|
-
apiKey: process.env.GRANTSIGNAL_API_KEY ||
|
|
17
|
+
/** Legacy: API key for Convex (kept for client.ts backward compat) */
|
|
18
|
+
apiKey: process.env.GRANTSIGNAL_API_KEY || "",
|
|
13
19
|
};
|
|
14
20
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,2BAA2B;IAC3B,WAAW,EACT,OAAO,CAAC,GAAG,CAAC,YAAY;QACxB,0CAA0C;IAE5C,iDAAiD;IACjD,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,EAAE;IAExD,6CAA6C;IAC7C,eAAe,EACb,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE;IAEnE,kEAAkE;IAClE,MAAM,EACJ,OAAO,CAAC,GAAG,CAAC,mBAAmB;QAC/B,uCAAuC;IAEzC,sEAAsE;IACtE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE;CAC9C,CAAC"}
|