API Key additional handling#18
Merged
DaInfernalCoder merged 1 commit intoDaInfernalCoder:mainfrom Oct 23, 2025
Merged
Conversation
…endencies and configuration - Added API Key handling with command-line arguments - Remove better-sqlite3 dependency - Add dotenv and minimist for improved configuration handling - Update TypeScript and Node.js type definitions - Update Node.js engine requirement to >=18.0.0 - Update README with additional configuration options for API key handling
Owner
|
sounds great, thanks for the pull! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
I have made some suggested changes to the Perplexity MCP Server's API key handling system to solve or workaround the issue in #17, and I will try to explain the technical reasoning behind the implementation decisions.
The Problem
Original Issue
The original README.md configuration suggested using
.envfiles with automatic discovery:{ "mcpServers": { "perplexity": { "command": "node", "args": ["/path/to/perplexity-server/build/index.js"], "env": { "PERPLEXITY_API_KEY": "YOUR_API_KEY_HERE" } } } }However, this approach has some flaws:
A simple solution would be to just put the PERPLEXITY_API_KEY in the system environment variables or make a bash script that loads the environment variables before starting Kiro, but I thought to come up with a more general approach.
The Solution
New Three-Tier API Key Resolution System
I implemented a simple system that provides multiple reliable methods:
Priority Order Rationale
The Perplexity API Key is searched with this priority.
Command-line Argument (Highest Priority)
Environment Variable (Preferred)
Explicit .env File (Lowest Priority)
--cwdIn this way, I can circumvent the problem of Kiro by passing the project directory with the .env file I am using for also the other MCP server using the
--cwdargument.Conclusion
I have changed the README file to explain how to use the new system, and I hope it will be useful.