@ythalorossy/openfda 1.0.12 → 1.0.13
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/LICENSE +20 -20
- package/README.md +84 -87
- package/bin/OpenFDABuilder.js +49 -49
- package/bin/OpenFDAClient.js +178 -178
- package/bin/index.js +616 -420
- package/bin/types.js +5 -5
- package/dist/index.js +648 -0
- package/package.json +21 -9
- package/build/OpenFDABuilder.js +0 -49
- package/build/OpenFDAClient.js +0 -178
- package/build/index.js +0 -452
- package/build/types.js +0 -5
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Ythalo Saldanha
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ythalo Saldanha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,87 +1,84 @@
|
|
|
1
|
-
# OpenFDA MCP Server
|
|
2
|
-
|
|
3
|
-
A Model Context Protocol (MCP) server for querying drug information from the OpenFDA API.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- Retrieve
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
[Buy me a Coffee](https://buymeacoffee.com/ythalorossy)
|
|
86
|
-
|
|
87
|
-

|
|
1
|
+
# OpenFDA MCP Server
|
|
2
|
+
|
|
3
|
+
A Model Context Protocol (MCP) server for querying drug information from the OpenFDA API.
|
|
4
|
+
|
|
5
|
+
<a href="https://glama.ai/mcp/servers/@ythalorossy/openfda">
|
|
6
|
+
<img width="380" height="200" src="https://glama.ai/mcp/servers/@ythalorossy/openfda/badge" alt="OpenFDA MCP server" />
|
|
7
|
+
</a>
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Retrieve drug label information by brand name
|
|
12
|
+
- Retrieve drug information by generic (active ingredient) name
|
|
13
|
+
- Get all brand versions of a generic drug
|
|
14
|
+
- Get adverse event (side effect) reports for a drug (by brand or generic name)
|
|
15
|
+
- Retrieve all drugs manufactured by a specific company
|
|
16
|
+
- Get comprehensive drug safety information (warnings, contraindications, interactions, precautions, etc.)
|
|
17
|
+
- Normalize and validate NDC (National Drug Code) formats
|
|
18
|
+
- Helpful error messages and suggestions for failed queries
|
|
19
|
+
|
|
20
|
+
1. **Set up your OpenFDA API Key**
|
|
21
|
+
|
|
22
|
+
The MCP server requires an OpenFDA API key to access the OpenFDA API.
|
|
23
|
+
Create a `.env` file in the root of your project and add the following line:
|
|
24
|
+
|
|
25
|
+
```env
|
|
26
|
+
OPENFDA_API_KEY=your_openfda_api_key_here
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> **Note:** Never commit your real API key to version control.
|
|
30
|
+
> You can obtain an API key from [OpenFDA API Key Registration](https://open.fda.gov/apis/authentication/).
|
|
31
|
+
|
|
32
|
+
2. **Example MCP Server Configuration**
|
|
33
|
+
|
|
34
|
+
If you are integrating this server with a larger MCP system, your configuration might look like:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"openfda": {
|
|
40
|
+
"command": "npx",
|
|
41
|
+
"args": ["@ythalorossy/openfda"],
|
|
42
|
+
"env": {
|
|
43
|
+
"OPENFDA_API_KEY": "************"
|
|
44
|
+
},
|
|
45
|
+
"timeout": 60000
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Replace the asterisks with your actual API key, or ensure it is loaded from your `.env` file.
|
|
52
|
+
|
|
53
|
+
## Want to run it locally?
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
git clone https://github.com/ythalorossy/openfda.git
|
|
57
|
+
cd openfda
|
|
58
|
+
npm install
|
|
59
|
+
npm run build
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then start the server:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
node bin/index.js
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or use it directly with npx:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npx @ythalorossy/openfda
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
Create a `.env` file for any required environment variables.
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT
|
|
81
|
+
|
|
82
|
+
[Buy me a Coffee](https://buymeacoffee.com/ythalorossy)
|
|
83
|
+
|
|
84
|
+

|
package/bin/OpenFDABuilder.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Ythalo Saldanha
|
|
3
|
-
* Licensed under the MIT License
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* The OpenFDABuilder class helps construct URLs for the OpenFDA API.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* - Set the context (such as 'label', 'ndc', or 'event') using the context() method.
|
|
10
|
-
* - Set the search query using the search() method.
|
|
11
|
-
* - Optionally set the result limit using the limit() method (default is 1).
|
|
12
|
-
* - Call build() to assemble and return the final API URL.
|
|
13
|
-
*
|
|
14
|
-
* Example:
|
|
15
|
-
* const url = new OpenFDABuilder()
|
|
16
|
-
* .context('label')
|
|
17
|
-
* .search('openfda.brand_name:"Advil"')
|
|
18
|
-
* .limit(1)
|
|
19
|
-
* .build();
|
|
20
|
-
*
|
|
21
|
-
* The build() method will throw an error if any required parameter is missing.
|
|
22
|
-
* The API key is read from the OPENFDA_API_KEY environment variable.
|
|
23
|
-
*/
|
|
24
|
-
export class OpenFDABuilder {
|
|
25
|
-
url = "https://api.fda.gov/drug/";
|
|
26
|
-
params = new Map();
|
|
27
|
-
context(context) {
|
|
28
|
-
this.params.set("context", context);
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
search(query) {
|
|
32
|
-
this.params.set("search", query);
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
limit(max = 1) {
|
|
36
|
-
this.params.set("limit", max);
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
build() {
|
|
40
|
-
const context = this.params.get("context");
|
|
41
|
-
const search = this.params.get("search");
|
|
42
|
-
const limit = this.params.get("limit");
|
|
43
|
-
const apiKey = process.env.OPENFDA_API_KEY;
|
|
44
|
-
if (!context || !search || !limit) {
|
|
45
|
-
throw new Error("Missing required parameters: context, search, or limit");
|
|
46
|
-
}
|
|
47
|
-
return `${this.url}${context}.json?api_key=${apiKey}&search=${search}&limit=${limit}`;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Ythalo Saldanha
|
|
3
|
+
* Licensed under the MIT License
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The OpenFDABuilder class helps construct URLs for the OpenFDA API.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* - Set the context (such as 'label', 'ndc', or 'event') using the context() method.
|
|
10
|
+
* - Set the search query using the search() method.
|
|
11
|
+
* - Optionally set the result limit using the limit() method (default is 1).
|
|
12
|
+
* - Call build() to assemble and return the final API URL.
|
|
13
|
+
*
|
|
14
|
+
* Example:
|
|
15
|
+
* const url = new OpenFDABuilder()
|
|
16
|
+
* .context('label')
|
|
17
|
+
* .search('openfda.brand_name:"Advil"')
|
|
18
|
+
* .limit(1)
|
|
19
|
+
* .build();
|
|
20
|
+
*
|
|
21
|
+
* The build() method will throw an error if any required parameter is missing.
|
|
22
|
+
* The API key is read from the OPENFDA_API_KEY environment variable.
|
|
23
|
+
*/
|
|
24
|
+
export class OpenFDABuilder {
|
|
25
|
+
url = "https://api.fda.gov/drug/";
|
|
26
|
+
params = new Map();
|
|
27
|
+
context(context) {
|
|
28
|
+
this.params.set("context", context);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
search(query) {
|
|
32
|
+
this.params.set("search", query);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
limit(max = 1) {
|
|
36
|
+
this.params.set("limit", max);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
build() {
|
|
40
|
+
const context = this.params.get("context");
|
|
41
|
+
const search = this.params.get("search");
|
|
42
|
+
const limit = this.params.get("limit");
|
|
43
|
+
const apiKey = process.env.OPENFDA_API_KEY;
|
|
44
|
+
if (!context || !search || !limit) {
|
|
45
|
+
throw new Error("Missing required parameters: context, search, or limit");
|
|
46
|
+
}
|
|
47
|
+
return `${this.url}${context}.json?api_key=${apiKey}&search=${search}&limit=${limit}`;
|
|
48
|
+
}
|
|
49
|
+
}
|