Skip to content

Commit

Permalink
Create MCP server
Browse files Browse the repository at this point in the history
  • Loading branch information
nielthiart committed Dec 18, 2024
0 parents commit 46991a4
Show file tree
Hide file tree
Showing 8 changed files with 662 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
build/
*.log
.env*
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Speakeasy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Mistral MCP Server Example

This is a TypeScript-based MCP server that provides two tools to chat with Mistral. It is a basic example of how to create a server that can be used with the [Model Context Protocol (MCP)](https://modelcontextprotocol.io).

## Blog Post

This repository is part of a blog post by Speakeasy: [Building a Mistral MCP Server](https://speakeasy.com/post/mcp-server).

## Requirements

- Node.js (tested on v20.17.10)
- An [MCP client](https://modelcontextprotocol.io/clients) that supports **tools**. We recommend: [Claude Desktop](https://claude.ai/download) or the [Cline VSCode extension](https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev).

## Mistral API key

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/).

## Tools

This server provides two tools:

- `mistral_chat_text` - Chat with Mistral using text input
- Takes a model and an array of text inputs
- Returns a text response from Mistral
- `mistral_chat_image` - Chat with Mistral using mixed text and image input
- Takes a model and an array of text and image inputs
- Images must be hosted on a public URL
- Returns a text response from Mistral

## Development

Install dependencies:

```bash
npm install
```

Build the server:

```bash
npm run build
```

For development with auto-rebuild:

```bash
npm run watch
```

## Installation

To use with Claude Desktop, add the server config:

On MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json` On
Windows: `%APPDATA%/Claude/claude_desktop_config.json`

```json
{
"mcpServers": {
"Mistral MCP Server": {
"command": "node",
"args": [
// Update this path to the location of the built server
"/Users/speakeasy/server-mistral/build/index.js"
],
"env": {
// Update this with your Mistral API key
"MISTRAL_API_KEY": "YOUR_MISTRAL_API_KEY"
}
}
}
}
```

### Debugging

Since MCP servers communicate over stdio, debugging can be challenging. We
recommend using the
[MCP Inspector](https://github.com/modelcontextprotocol/inspector), which is
available as a package script:

```bash
npm run inspector
```

The Inspector will provide a URL to access debugging tools in your browser.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
252 changes: 252 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 46991a4

Please sign in to comment.