Skip to content

Instantly share code, notes, and snippets.

@koji
Created March 22, 2025 03:14
Show Gist options
  • Save koji/b8228643978a6be2539b7aefec45e5c0 to your computer and use it in GitHub Desktop.
Save koji/b8228643978a6be2539b7aefec45e5c0 to your computer and use it in GitHub Desktop.
get sample mcp config for asdf env
#!/bin/bash

# Get full path to npx
FULL_PATH_TO_NPX=$(which npx)

# Extract ASDF shims directory (remove '/npx' from the path)
PATH_TO_ASDF_SHIMS_DIR=$(dirname "$FULL_PATH_TO_NPX")

# Get full path to asdf
FULL_PATH_TO_ASDF=$(which asdf)

# Extract ASDF bin directory (remove '/asdf' from the path)
PATH_TO_ASDF_BIN_DIR=$(dirname "$FULL_PATH_TO_ASDF")

# Get current Node.js version managed by asdf
ASDF_NODEJS_VERSION=$(asdf current nodejs | grep -oE '[0-9]+(\.[0-9]+)*')


# Output JSON configuration
cat <<EOF
{
  "brave-search": {
    "command": "$FULL_PATH_TO_NPX",
    "args": [
      "-y",
      "@modelcontextprotocol/server-brave-search"
    ],
    "env": {
      "BRAVE_API_KEY": "YOUR_API_KEY_HERE",
      "PATH": "$PATH_TO_ASDF_SHIMS_DIR:$PATH_TO_ASDF_BIN_DIR:/usr/bin:/bin",
      "ASDF_NODEJS_VERSION": "$ASDF_NODEJS_VERSION"
    }
  }
}
EOF
@nickfun
Copy link

nickfun commented Jul 15, 2025

Found this by googling, very helpful, thanks for sharing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment