Skip to content

feat: Implement MCP List Tools #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 0 additions & 111 deletions .devcontainer/.zshrc

This file was deleted.

19 changes: 15 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
FROM mcr.microsoft.com/devcontainers/rust:1.0.20-bookworm

ENV ZSH_CUSTOM=/home/vscode/.oh-my-zsh/custom \
TASK_VERSION=v3.41.0
ENV TASK_VERSION=v3.43.3

RUN apt-get update && \
# Install GitHub CLI
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && \
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \
apt-get update && \
apt-get install -y gh && \
# Install nodejs and npm
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
# Install Task
Expand All @@ -14,6 +19,12 @@ RUN apt-get update && \

RUN npm install -g semantic-release @semantic-release/changelog @semantic-release/exec @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits

RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM}/themes/powerlevel10k

USER vscode

# Use Powerlevel10k theme
RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git /home/vscode/.powerlevel10k && \
Copy link
Preview

Copilot AI May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider pinning the powerlevel10k repository to a specific commit or tag to prevent potential breakage from upstream changes. This would improve the long-term stability of the development environment.

Suggested change
RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git /home/vscode/.powerlevel10k && \
RUN git clone https://github.com/romkatv/powerlevel10k.git /home/vscode/.powerlevel10k && \
cd /home/vscode/.powerlevel10k && \
git checkout 1.18.0 && \

Copilot uses AI. Check for mistakes.

echo 'source /home/vscode/.powerlevel10k/powerlevel10k.zsh-theme' >> /home/vscode/.zshrc && \
echo 'POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true' >> /home/vscode/.zshrc

RUN echo "source <(task --completion zsh)" >> /home/vscode/.zshrc
RUN echo "source <(gh completion -s zsh)" >> /home/vscode/.zshrc
45 changes: 40 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "Debian with Rust",
"dockerFile": "Dockerfile",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:latest": {}
},
"customizations": {
"vscode": {
"extensions": [
Expand Down Expand Up @@ -33,14 +36,46 @@
"dev.containers.copyGitConfig": true,
"githubPullRequests.experimental.chat": true,
"githubPullRequests.experimental.notificationsView": true,
"files.insertFinalNewline": true
"files.insertFinalNewline": true,
"github.copilot.enable": {
"*": true
},
"github.copilot.advanced": {
"authProvider": "github"
},
"github.copilot.chat.codeGeneration.useInstructionFiles": true,
"github.copilot.chat.codeGeneration.instructions": [
{
"file": ".github/copilot-instructions.md"
},
{
"file": "../README.md"
}
],
"github.copilot.chat.commitMessageGeneration.instructions": [
{
"text": "Always use conventional commit message format."
}
],
"mcp": {
"servers": {
"context7": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"node:lts",
"npx",
"-y",
"@upstash/context7-mcp@latest"
]
}
}
}
}
}
},
"mounts": [
"source=${localWorkspaceFolder}/.devcontainer/.zshrc,target=/home/vscode/.zshrc,type=bind,consistency=cached",
"source=${localWorkspaceFolder}/.devcontainer/launch.json,target=/workspaces/inference-gateway/rust-sdk/.vscode/launch.json,type=bind,consistency=cached"
],
"remoteEnv": {
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
}
Expand Down
15 changes: 0 additions & 15 deletions .devcontainer/launch.json

This file was deleted.

49 changes: 49 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Custom Instructions for Copilot

Today is May 26, 2025.

- Always use context7 to check for the latest updates, features, or best practices of a library relevant to the task at hand.
- Always prefer Table-Driven Testing: When writing tests.
- Always use Early Returns: Favor early returns to simplify logic and avoid deep nesting with if-else structures.
- Always prefer switch statements over if-else chains: Use switch statements for cleaner and more readable code when checking multiple conditions.
- Always run `task analyse` to ensure code quality and catch potential issues before committing.
- Always run `task lint` before committing code to ensure it adheres to the project's linting rules.
- Always run `task test` before committing code to ensure all tests pass.
- Always search for the simplest solution first before considering more complex alternatives.
- Always prefer type safety over dynamic typing: Use strong typing and interfaces to ensure type safety and reduce runtime errors.
- When working on MCP (Model Context Protocol) related tasks, always refer to the official MCP documentation and examples for guidance and ensure you run `task jrpc-mcp-schema-download` and `task generate` to keep the MCP Golang types up to date.
- When possible code to an interface so it's easier to mock in tests.
- When writing tests, each test case should have it's own isolated mock server mock dependecies so it's easier to understand and maintain.

## Development Workflow

### Configuration Changes

When adding new configuration fields:

1. Run `task oas-download` - OpenAPI is the source of truth - readonly file.
2. If added new Schemas to openapi.yaml, update internal/openapi/schemas.go to include the new schemas
3. Run `task lint` to ensure code quality
4. Run `task analyse` to catch potential issues
5. Run `task test` to ensure all tests pass
6. Update the README.md file or any documentation files with the recently added implementation

## Available Tools and MCPs

- context7 - Helps by finding the latest updates, features, or best practices of a library relevant to the task at hand.

## Related Repositories

- [Inference Gateway](https://github.com/inference-gateway)
- [Inference Gateway UI](https://github.com/inference-gateway/ui)
- [Go SDK](https://github.com/inference-gateway/go-sdk)
- [Rust SDK](https://github.com/inference-gateway/rust-sdk)
- [TypeScript SDK](https://github.com/inference-gateway/typescript-sdk)
- [Documentation](https://github.com/inference-gateway/docs)

## MCP Useful links

- [Introduction](https://modelcontextprotocol.io/introduction)
- [Specification](https://modelcontextprotocol.io/specification)
- [Examples](https://modelcontextprotocol.io/examples)
- [Schema](https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/refs/heads/main/schema/draft/schema.json)
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ An SDK written in Rust for the [Inference Gateway](https://github.com/inference-
- [Creating a Client](#creating-a-client)
- [Listing Models](#listing-models)
- [Listing Models from a specific provider](#listing-models-from-a-specific-provider)
- [Listing MCP Tools](#listing-mcp-tools)
- [Generating Content](#generating-content)
- [Streaming Content](#streaming-content)
- [Tool-Use](#tool-use)
Expand All @@ -32,6 +33,7 @@ use inference_gateway_sdk::{
InferenceGatewayAPI,
InferenceGatewayClient,
ListModelsResponse,
ListToolsResponse,
Message,
Provider,
MessageRole
Expand Down Expand Up @@ -137,6 +139,41 @@ for model in response.data {
// ...Rest of the main function
```

### Listing MCP Tools

To list all available MCP (Model Context Protocol) tools from all configured MCP servers, use the `list_tools` method:

```rust
use inference_gateway_sdk::{
GatewayError,
InferenceGatewayAPI,
InferenceGatewayClient,
ListToolsResponse,
};
use log::info;

#[tokio::main]
async fn main() -> Result<(), GatewayError> {
// ...Create a client

// List all MCP tools from all configured servers
let response: ListToolsResponse = client.list_tools().await?;
info!("Found {} MCP tools", response.data.len());

for tool in response.data {
info!("Tool: {} from server: {}", tool.name, tool.server);
info!("Description: {}", tool.description);
if let Some(schema) = &tool.input_schema {
info!("Input schema: {}", schema);
}
}

Ok(())
}
```

Note: This functionality requires that MCP servers are configured and exposed in your Inference Gateway instance. If MCP is not exposed, you'll receive a `403 Forbidden` error.

### Generating Content

To generate content using a model, use the `generate_content` method:
Expand Down
Loading