@ythalorossy/openfda 1.0.11 → 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 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
- ## Features
6
-
7
- - Retrieve drug label information by brand name
8
- - Retrieve drug information by generic (active ingredient) name
9
- - Get all brand versions of a generic drug
10
- - Get adverse event (side effect) reports for a drug (by brand or generic name)
11
- - Retrieve all drugs manufactured by a specific company
12
- - Get comprehensive drug safety information (warnings, contraindications, interactions, precautions, etc.)
13
- - Normalize and validate NDC (National Drug Code) formats
14
- - Helpful error messages and suggestions for failed queries
15
-
16
- 1. **Set up your OpenFDA API Key**
17
-
18
- The MCP server requires an OpenFDA API key to access the OpenFDA API.
19
- Create a `.env` file in the root of your project and add the following line:
20
-
21
- ```env
22
- OPENFDA_API_KEY=your_openfda_api_key_here
23
- ```
24
-
25
- > **Note:** Never commit your real API key to version control.
26
- > You can obtain an API key from [OpenFDA API Key Registration](https://open.fda.gov/apis/authentication/).
27
-
28
- 2. **Example MCP Server Configuration**
29
-
30
- If you are integrating this server with a larger MCP system, your configuration might look like:
31
-
32
- ```json
33
- {
34
- "mcpServers": {
35
- "openfda": {
36
- "command": "npx",
37
- "args": ["@ythalorossy/openfda"],
38
- "env": {
39
- "OPENFDA_API_KEY": "************"
40
- },
41
- "timeout": 60000
42
- }
43
- }
44
- }
45
- ```
46
-
47
- Replace the asterisks with your actual API key, or ensure it is loaded from your `.env` file.
48
-
49
- ## Want to run it local?
50
-
51
- ```bash
52
- git clone https://github.com/ythalorossy/openfda.git
53
- cd openfda
54
- npm install
55
- ```
56
-
57
- ## Usage
58
-
59
- First, build the project:
60
-
61
- ```bash
62
- npm run build
63
- ```
64
-
65
- Then, start the server from the build folder:
66
-
67
- ```bash
68
- node build/index.js
69
- ```
70
-
71
- **Key Points:**
72
- - The build step (`npm run build`) compiles your source files into the build/ directory.
73
- - You should run the compiled output (e.g., `build/bin/index.js`), not the source file (`bin/index.js`), unless your project is set up to run directly from source.
74
-
75
-
76
- ## Configuration
77
-
78
- Create a `.env` file for any required environment variables.
79
-
80
- ## License
81
-
82
- MIT
83
-
84
-
85
- [Buy me a Coffee](https://buymeacoffee.com/ythalorossy)
86
-
87
- ![coff.ee/ythalorossy](https://raw.githubusercontent.com/ythalorossy/openfda/refs/heads/main/bmc_qr.png "Buy me a Coffee")
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
+ ![coff.ee/ythalorossy](https://raw.githubusercontent.com/ythalorossy/openfda/refs/heads/main/bmc_qr.png "Buy me a Coffee")
@@ -1,45 +1,49 @@
1
- /**
2
- * The OpenFDABuilder class helps construct URLs for the OpenFDA API.
3
- *
4
- * Usage:
5
- * - Set the context (such as 'label', 'ndc', or 'event') using the context() method.
6
- * - Set the search query using the search() method.
7
- * - Optionally set the result limit using the limit() method (default is 1).
8
- * - Call build() to assemble and return the final API URL.
9
- *
10
- * Example:
11
- * const url = new OpenFDABuilder()
12
- * .context('label')
13
- * .search('openfda.brand_name:"Advil"')
14
- * .limit(1)
15
- * .build();
16
- *
17
- * The build() method will throw an error if any required parameter is missing.
18
- * The API key is read from the OPENFDA_API_KEY environment variable.
19
- */
20
- export class OpenFDABuilder {
21
- url = "https://api.fda.gov/drug/";
22
- params = new Map();
23
- context(context) {
24
- this.params.set("context", context);
25
- return this;
26
- }
27
- search(query) {
28
- this.params.set("search", query);
29
- return this;
30
- }
31
- limit(max = 1) {
32
- this.params.set("limit", max);
33
- return this;
34
- }
35
- build() {
36
- const context = this.params.get("context");
37
- const search = this.params.get("search");
38
- const limit = this.params.get("limit");
39
- const apiKey = process.env.OPENFDA_API_KEY;
40
- if (!context || !search || !limit) {
41
- throw new Error("Missing required parameters: context, search, or limit");
42
- }
43
- return `${this.url}${context}.json?api_key=${apiKey}&search=${search}&limit=${limit}`;
44
- }
45
- }
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
+ }