Constants
Using constants in the MCPlug client
Constants provide a secure method for passing sensitive values to MCP servers. These include API keys, authentication tokens, and configuration parameters that should remain hidden from the LLM and necessary for the MCP server to function.
There is two ways of settings constant within a plug:
- In the dashboard: In the “Constants” tabs, this will set some sort of default values for the plug.
- In the client: When initializing the mcplug client, provide constants as part of the configuration. Provided constants will override the ones in the dashboard.
When using MCPlug inside a MCP host like Cursor or Claude. You can still set default values for the constants in the “Constants” tab of the MCP host but you can override them by passing constants in the “env” property.
Passing Constants to the Client
When initializing the mcplug client, provide constants as part of the configuration:
How Constants Work
On the server side, constants are identified by an underscore prefix (_
) in the tool’s input schema. When you provide these constants during client initialization, they’re automatically passed to the corresponding tools when called.
This approach keeps sensitive information secure, as the LLM has no access to these constants.
Weather API Example
Consider a weather MCP server requiring a paid API key to fetch weather data for specific cities:
- The MCP server developer creates a
getWeather
tool that requires a city name and theWEATHER_API_KEY
constant - You provide the API key during client initialization
Gmail Integration Example
For Gmail tool integration:
- You must provide all necessary authentication credentials
- Mcplug doesn’t generate these credentials
- You’ll need to create your own OAuth2.0 client ID and client secret and store them securely
- Store the refresh token in your database as well
Once you have the required credentials, pass them to the client as constants: