Skip to content

SchemeName is not replaced properly in OAuth env #56

@linastehle

Description

@linastehle

Describe the bug
OAuth authentication with clientId and clientSecret does not work properly, as the code is not replacing the SCHEMENAME correctly

To Reproduce
Steps to reproduce the behavior:

  1. Use an oauth2 security scheme in the openapi spec file, e.g. with name myscheme
  2. Generate the MCP server with command openapi-mcp-generator --transport "web" --input ./pkg/spec/my-api.yml --output ./my-api-mcp --base-url "https://my-api.sample/rest/api"
  3. Provide the variables in the generated .env file:
OAUTH_CLIENT_ID_MYSCHEME=789
OAUTH_CLIENT_SECRET_MYSCHEME=xyz
  1. The generated code in file index.ts contains the following code:
async function acquireOAuth2Token(schemeName: string, scheme: any): Promise<string | null | undefined> {
    try {
        // Check if we have the necessary credentials
        const clientId = process.env[`OAUTH_CLIENT_ID_SCHEMENAME`];
        const clientSecret = process.env[`OAUTH_CLIENT_SECRET_SCHEMENAME`];
        const scopes = process.env[`OAUTH_SCOPES_SCHEMENAME`];

whereas it should read the variables OAUTH_CLIENT_ID_MYSCHEME and OAUTH_CLIENT_SECRET_MYSCHEME

Expected behavior
The generated MCP server executes the necessary steps to obtain a token with provided clientId and clientSecret.

Desktop (please complete the following information):

  • OS: macOS Tahoe 26.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions