Skip to content

Commit 5bddd0b

Browse files
authored
docs: Add more examples how to use this sdk (#16)
* docs(examples): Add example environment configuration and README files for SDK usage Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs: Update README to include pre-requisites for using the Typescript SDK examples Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(examples): Update example links in README and add list example README Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(examples): Add examples for chat, list, and MCP using Inference Gateway SDK - Created a chat example with package.json, tsconfig.json, and index.ts to demonstrate chat completions and streaming responses. - Added a list example with package.json, tsconfig.json, and index.ts for listing models and MCP tools. - Included README.md files for both chat and list examples with instructions for getting started. - Added .gitignore files to exclude node_modules in both list and MCP examples. Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(exmaples): Add sample files and configuration for MCP example - Created a new directory with sample files for the MCP filesystem server, including `sample.txt`, `data.json`, and `config.yaml`. - Added a README.md file to describe the purpose and usage of the sample data. - Implemented a TypeScript configuration file (`tsconfig.json`) for the MCP example. - Created a package.json and package-lock.json for managing dependencies in the examples directory. - Updated the OpenAPI specification to include new endpoints and improved formatting for consistency. Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(examples): Update LLM model references to remove provider prefix Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(mcp): Add note to ensure no containers are running before starting the example Signed-off-by: Eden Reich <eden.reich@gmail.com> * feat: Support both local tools and remote MCP tools; Add onMCPTool callback - Created a new MCP Web Search Server with a package.json file. - Updated the main MCP package.json to include example scripts for remote and local tools. - Added a .gitignore file in the shared directory to exclude unnecessary files. - Removed outdated README.md, config.yaml, data.json, and sample.txt files from the shared directory. - Introduced a new sample_sales_data.csv file for demonstration purposes. - Enhanced the client.ts to support MCP tool callbacks and improved streaming response processing. Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(examples): Refactor MCP examples and client for improved error handling and token tracking - Updated docker-compose.yml to set environment to production and commented out optional Ollama service. - Enhanced example-mcp-tools.ts to use console.info for logging and added model availability checks. - Modified index.ts to implement token tracking for prompt and completion tokens, displaying usage metrics at the end. - Improved filesystem MCP server (index.js) to use console.info for logging and ensure consistent messaging. - Updated web-search MCP server (index-http.js and index.js) to use console.info for logging and improved request handling. - Enhanced InferenceGatewayClient to handle mid-stream errors and added type definitions for stream chunks that may contain errors. Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(examples) Add more examples and MCP server to MCP examples Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(examples): Add NPM MCP server with whitelisted command execution and project management tools Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs: Update context7 server package and dependencies, improve npm command timeouts - Renamed mcp-context7-server to context7-http-bridge and updated description in package.json. - Updated dependencies: - Changed @modelcontextprotocol/sdk version to ^0.5.0. - Added @upstash/context7-mcp as a dependency. - Updated zod to ^3.22.4. - Changed dev script to use nodemon for development. - Increased timeout for npm command execution from 30 seconds to 5 minutes. - Increased timeout for project creation from 3 minutes to 10 minutes. - Added a clean script to remove shared directories in mcp package.json. - Renamed example:context7 to example:agent in mcp package.json. - Increased default timeout in InferenceGatewayClient to 60 seconds. Signed-off-by: Eden Reich <eden.reich@gmail.com> * chore(mcp-agent-example): Enhance retry logic and improve system prompt for Context7 agent I need to fix in the Inference Gateway or find a solution for DeepSeek 30seconds timeout - it's annoying. Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(example-agent): Add wait functionality for Next.js project creation and update system prompt Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(examples): Remove outdated examples and add Vite agent for modern application development - Deleted example-npm.ts and example-tool-demo.ts as they are no longer needed. - Introduced example-vite-agent.ts to facilitate the creation of Vite-based applications. - Updated package.json to reflect the removal of old examples and the addition of the new Vite agent. - Cleaned up filesystem server code by removing unnecessary comments and simplifying allowed directories. - Removed sample_sales_data.csv as it is no longer relevant to the current examples. Signed-off-by: Eden Reich <eden.reich@gmail.com> * chore: Add Vite agent and Docker Compose configuration for MCP - Created a new package.json for the Vite agent with necessary dependencies and scripts. - Added a Docker Compose configuration file to manage multiple agents including Kubernetes, Vite, and Next.js. - Removed the outdated README for MCP servers as part of the restructuring. Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs: Implement MCP Memory Server for state persistence and error recovery Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(examples-fix): Update @inference-gateway/sdk to version 0.7.2 and rename tool callback to onMCPTool Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(examples): Add delete_directory tool with optional recursive deletion to MCP filesystem server Signed-off-by: Eden Reich <eden.reich@gmail.com> * fix: Rename Context7Agent to NextJSAgent and update related messages Signed-off-by: Eden Reich <eden.reich@gmail.com> * fix: Update entry point check for Kubernetes and Vite agents to use 'index.ts' Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs: Enhance README with additional instructions for spinning up the Inference Gateway and MCP Server Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Enhance MCP Web Search server with structured logging and error handling - Introduced a standardized Winston logger for consistent logging across the MCP server. - Added middleware for logging incoming requests and their completion details. - Enhanced error handling in tools, providing structured error responses. - Implemented HTML content extraction using Cheerio, with options for plain text extraction. - Updated the fetch_url tool to log detailed fetch operations and handle various content types. - Improved logging for web search and page title extraction tools. - Added health check endpoint logging. - Updated package dependencies to include Winston for logging. Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Implement DuckDuckGo search functionality with safe search options Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Upgrade Node.js version in Dockerfiles and add MCP Inspector service Still need to figure out why I cannot connect to the other services using the inspector Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Enhance logging and error handling in MCP Memory Server Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Clean up unneeded comments Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Remove redundant comments and improve code clarity in MCP Filesystem Server Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Remove redundant comment in Context7Process class Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Update @inference-gateway/sdk version to ^0.7.3 and improve model configuration in multiple agents Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Increase maxTokensPerRequest to 3000 and update related max_tokens settings Signed-off-by: Eden Reich <eden.reich@gmail.com> * chore: Add tools for saving and managing conversation state in MCP Memory Server Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Replace process.stdout.write with console.log for improved logging consistency Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Enhance KubernetesAgent with memory management features and optimize request handling Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Refactor MCP Memory Server to use MemoryManager for in-memory operations - Removed healthcheck from docker-compose.yml for the MCP service. - Introduced MemoryManager class for efficient in-memory storage with background persistence. - Replaced file I/O operations with in-memory methods in index.js for saving, restoring, and managing session data. - Implemented automatic background persistence for dirty sessions in MemoryManager. - Enhanced error handling and logging throughout the memory management process. - Updated server startup and shutdown procedures to integrate MemoryManager lifecycle. Signed-off-by: Eden Reich <eden.reich@gmail.com> * docs(examples): Add Brave Search server package and TypeScript configuration - Created package.json for the MCP Brave Search server with necessary dependencies and scripts. - Added tsconfig.json for TypeScript configuration, specifying compiler options and file inclusion/exclusion. Signed-off-by: Eden Reich <eden.reich@gmail.com> * refactor: Improve error handling and logging in MarketingAgent Signed-off-by: Eden Reich <eden.reich@gmail.com> --------- Signed-off-by: Eden Reich <eden.reich@gmail.com>
1 parent 8839d66 commit 5bddd0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+20997
-2032
lines changed

examples/mcp/.env.example

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
# General settings
3+
ENVIRONMENT=development
4+
ENABLE_TELEMETRY=false
5+
ENABLE_AUTH=false
6+
# Model Context Protocol (MCP)
7+
MCP_ENABLE=false
8+
MCP_EXPOSE=false
9+
MCP_SERVERS=
10+
MCP_CLIENT_TIMEOUT=5s
11+
MCP_DIAL_TIMEOUT=3s
12+
MCP_TLS_HANDSHAKE_TIMEOUT=3s
13+
MCP_RESPONSE_HEADER_TIMEOUT=3s
14+
MCP_EXPECT_CONTINUE_TIMEOUT=1s
15+
MCP_REQUEST_TIMEOUT=5s
16+
# OpenID Connect
17+
OIDC_ISSUER_URL=http://keycloak:8080/realms/inference-gateway-realm
18+
OIDC_CLIENT_ID=inference-gateway-client
19+
OIDC_CLIENT_SECRET=
20+
# Server settings
21+
SERVER_HOST=0.0.0.0
22+
SERVER_PORT=8080
23+
SERVER_READ_TIMEOUT=30s
24+
SERVER_WRITE_TIMEOUT=30s
25+
SERVER_IDLE_TIMEOUT=120s
26+
SERVER_TLS_CERT_PATH=
27+
SERVER_TLS_KEY_PATH=
28+
# Client settings
29+
CLIENT_TIMEOUT=30s
30+
CLIENT_MAX_IDLE_CONNS=20
31+
CLIENT_MAX_IDLE_CONNS_PER_HOST=20
32+
CLIENT_IDLE_CONN_TIMEOUT=30s
33+
CLIENT_TLS_MIN_VERSION=TLS12
34+
# Providers
35+
ANTHROPIC_API_URL=https://api.anthropic.com/v1
36+
ANTHROPIC_API_KEY=
37+
CLOUDFLARE_API_URL=https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai
38+
CLOUDFLARE_API_KEY=
39+
COHERE_API_URL=https://api.cohere.ai
40+
COHERE_API_KEY=
41+
GROQ_API_URL=https://api.groq.com/openai/v1
42+
GROQ_API_KEY=
43+
OLLAMA_API_URL=http://ollama:8080/v1
44+
OLLAMA_API_KEY=
45+
OPENAI_API_URL=https://api.openai.com/v1
46+
OPENAI_API_KEY=
47+
DEEPSEEK_API_URL=https://api.deepseek.com
48+
DEEPSEEK_API_KEY=
49+
50+
# Chosen provider
51+
PROVIDER=deepseek
52+
LLM=deepseek-chat
53+
54+
# Brave search
55+
BRAVE_API_KEY=

0 commit comments

Comments
 (0)