From 0ddd1a38f38e4f81e041f0f5485c15ab94b75e82 Mon Sep 17 00:00:00 2001 From: Niel Thiart Date: Thu, 19 Dec 2024 16:28:36 +0200 Subject: [PATCH] Add environment configuration and update README instructions --- .env.example | 1 + .gitignore | 2 +- README.md | 13 +++++++++++++ src/index.ts | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..36b8cd7 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +MISTRAL_API_KEY="YOUR_MISTRAL_API_KEY" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7f106e9..7b02baa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ node_modules/ build/ *.log -.env* \ No newline at end of file +.env \ No newline at end of file diff --git a/README.md b/README.md index 333340e..dec8de4 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,19 @@ This repository is part of a blog post by Speakeasy: [Building a Mistral MCP Ser To interact with the Mistral AI platform, you'll need an API key. You can get one by signing up at [mistral.ai](https://mistral.ai/). +Set your API key as an environment variable. Create a copy of `.env.example` and rename it to `.env`. + +```bash +cp .env.example .env +open .env +``` + +Then update the `.env` file with your API key: + +```bash +MISTRAL_API_KEY="YOUR_MISTRAL_API_KEY" +``` + ## Tools This server provides two tools: diff --git a/src/index.ts b/src/index.ts index 32bbe51..47c02d4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node - +import path from "path"; import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { @@ -18,7 +18,7 @@ import { } from "./schema.js"; import dotenv from "dotenv"; -dotenv.config(); +dotenv.config({path: path.join(import.meta.dirname, "..", ".env")}); const server = new Server( {