crm_OBUO_FARMSClientOrderForm.tsx7 matches
29const feedTypes = ['Fish Feed', 'Poultry Feed'] as const;
3031// Fetch products on component mount
32useEffect(() => {
33fetchProducts();
34}, []);
3539}, [formData.productCategory, formData.fishType, formData.productForm, formData.poultryType, formData.eggType, formData.feedType]);
4041const fetchProducts = async () => {
42try {
43const response = await fetch('/api/products');
44const result: ApiResponse<Product[]> = await response.json();
45if (result.success && result.data) {
47}
48} catch (error) {
49console.error('Failed to fetch products:', error);
50}
51};
110111try {
112const response = await fetch('/api/orders', {
113method: 'POST',
114headers: {
137
138// Refresh products to get updated stock
139await fetchProducts();
140
141// Scroll to top to show success message
mcp-servermain.ts7 matches
1import { Hono, Context } from 'npm:hono';
2import { SSETransport } from 'npm:hono-mcp-server-sse-transport';
3import { toFetchResponse, toReqRes } from "npm:fetch-to-node";
4import { z } from "npm:zod";
5import lunr from "https://cdn.skypack.dev/lunr";
197198try {
199console.log("Fetching site contents...");
200const [searchData, proverbs] = await Promise.all([
201fetch("https://www.joshbeckman.org/assets/js/SearchData.json").then((res) => res.json()),
202fetch("https://www.joshbeckman.org/assets/js/proverbs.json").then((res) => res.json())
203]);
204const db: Array<Post> = Object.values(searchData).filter(postFilter).map((post) => {
215const index = buildIndex(searchData);
216const tagsIndex = buildTagsIndex(tags);
217console.log("Successfully fetched site contents");
218219console.log("Registering tools...");
403});
404405return toFetchResponse(res);
406} catch (e) {
407console.error(e);
454* This will be exposed as a Val.town HTTP endpoint
455*/
456export default app.fetch;
457
ChatStreamingChat.tsx7 matches
5import { AnthropicStreamEvent, MCPPrompt } from "../../shared/types.ts";
6import useAnthropicStream from "../hooks/useAnthropicStream.tsx";
7import { fetchMCPPromptsWithCache } from "../utils/mcpPrompts.ts";
8import { AppConfig, Message } from "./App.tsx";
9import CommandPalette from "./CommandPalette.tsx";
106}, [input]);
107108/* fetch MCP prompts when config changes */
109useEffect(() => {
110const fetchPrompts = async () => {
111try {
112const result = await fetchMCPPromptsWithCache(config.mcpServers);
113114if (result.success) {
116setPrompts(result.prompts);
117} else {
118console.warn("Failed to fetch MCP prompts:", result.error);
119// Keep existing prompts on error
120}
121} catch (error) {
122console.warn("Failed to fetch MCP prompts:", error);
123// Keep existing prompts on error
124}
126127if (config.mcpServers.some(s => s.enabled && s.url)) {
128fetchPrompts();
129} else {
130// If no servers are enabled, just show the built-in test prompt
24- **Structured display of MCP tool calls and results** to prevent truncation
25- **Frontend MCP server testing** - test button for each MCP server with visual status indicators (โ /โ)
26- **Frontend MCP prompt fetching** - prompts are fetched directly from MCP servers with caching support
2728## Streaming Implementation
54โ โโโ utils/
55โ โ โโโ mcpTesting.ts # Frontend MCP server testing
56โ โ โโโ mcpPrompts.ts # Frontend MCP prompt fetching
57โ โโโ style.css # Custom styles with streaming animations
58โโโ shared/
75- `GET /shared/*` - Shared utility files
7677**Note**: MCP server testing and prompt fetching are now handled directly on the frontend for improved performance and reduced server load.
7879## Usage
ChatmcpTesting.ts4 matches
6465try {
66const response = await fetch(server.url, {
67method: "POST",
68headers,
97};
98}
99} catch (fetchError: any) {
100clearTimeout(timeoutId);
101
102if (fetchError.name === "AbortError") {
103return {
104success: false,
107}
108
109throw fetchError;
110}
111} catch (error: any) {
ChatmcpPrompts.ts20 matches
2* Frontend MCP Prompts Utility
3*
4* Handles fetching prompts from MCP servers directly from the frontend
5* without requiring backend proxy endpoints.
6*/
2324/**
25* Fetch prompts from a single MCP server
26* @param server - MCP server configuration
27* @returns Promise<MCPPrompt[]>
28*/
29async function fetchPromptsFromServer(server: MCPServerConfig): Promise<MCPPrompt[]> {
30if (!server.enabled || !server.url) {
31return [];
47try {
48// First, initialize the connection
49const initResponse = await fetch(server.url, {
50method: "POST",
51headers,
71}
7273// Then fetch prompts
74const promptsResponse = await fetch(server.url, {
75method: "POST",
76headers,
100}
101}
102} catch (fetchError: any) {
103clearTimeout(timeoutId);
104105if (fetchError.name === "AbortError") {
106console.warn(`Timeout fetching prompts from ${server.name}`);
107} else {
108throw fetchError;
109}
110}
112return [];
113} catch (error) {
114console.warn(`Failed to fetch prompts from ${server.name}:`, error);
115return [];
116}
118119/**
120* Fetch prompts from all enabled MCP servers
121* @param servers - Array of MCP server configurations
122* @returns Promise<MCPPromptsResult>
123*/
124export async function fetchMCPPrompts(servers: MCPServerConfig[]): Promise<MCPPromptsResult> {
125try {
126if (!servers || !Array.isArray(servers)) {
141}
142143// Fetch prompts from all enabled servers concurrently
144const promptPromises = enabledServers.map(server => fetchPromptsFromServer(server));
145const promptArrays = await Promise.all(promptPromises);
146175176/**
177* Fetch prompts with caching support
178* @param servers - Array of MCP server configurations
179* @param cacheKey - Optional cache key for localStorage
181* @returns Promise<MCPPromptsResult>
182*/
183export async function fetchMCPPromptsWithCache(
184servers: MCPServerConfig[],
185cacheKey: string = "mcp_prompts_cache",
202}
203204// Fetch fresh data
205const result = await fetchMCPPrompts(servers);
206207// Cache successful results
223try {
224const { data } = JSON.parse(cached);
225console.warn("Using stale cached prompts due to fetch error:", error);
226return {
227success: true,
projectTreemain.ts1 match
22);
2324export default app.fetch;
25
test-yt-transcriptmain.tsx1 match
3let videoId = "https://www.youtube.com/watch?v=5orZtBqftE8";
4console.log("starting...");
5let x = YoutubeTranscript.fetchTranscript(videoId);
6console.log(x);
7};
crm_OBUO_FARMSproducts.ts10 matches
20});
21} catch (error) {
22console.error('Error fetching products:', error);
23return c.json<ApiResponse<null>>({
24success: false,
25error: "Failed to fetch products"
26}, 500);
27}
37});
38} catch (error) {
39console.error('Error fetching low stock products:', error);
40return c.json<ApiResponse<null>>({
41success: false,
42error: "Failed to fetch low stock products"
43}, 500);
44}
69});
70} catch (error) {
71console.error('Error fetching product:', error);
72return c.json<ApiResponse<null>>({
73success: false,
74error: "Failed to fetch product"
75}, 500);
76}
259});
260} catch (error) {
261console.error('Error fetching stock movements:', error);
262return c.json<ApiResponse<null>>({
263success: false,
264error: "Failed to fetch stock movements"
265}, 500);
266}
278});
279} catch (error) {
280console.error('Error fetching all stock movements:', error);
281return c.json<ApiResponse<null>>({
282success: false,
283error: "Failed to fetch stock movements"
284}, 500);
285}